25729

Python3.3 - Fatal Python error: Py_Initialize: Unable to get the locale encoding

Question:

ImportError: No module named 'encodings'

While the error is self explaining, I know the cause of the issue. The problem is that the platform is using colon in their path name so when I set the path using:

Py_SetPath("the/path/with:colon/");

And then call:

Py_Initialize();

It fails to find the required modules to import. So, my question is: Is there any way to workaround without renaming the path (which I'm not controlling)? Can I somehow escape the colons?

Thanks!

Answer1:

From the looks of the <a href="http://hg.python.org/cpython/file/8fe2bb0c5851/Modules/getpath.c#l823" rel="nofollow">source code</a>, there is no way to do this that I can see...

Py_SetPath simply clears out any path that may have been set previously and then resets it to the string you give it with no real processing. That is what gets returned by Py_GetPath and that's all there is to it I suppose.

One suggestion that <em>might</em> work is to create a symbolic link to the directory somewhere where there isn't a : in the path name and use that instead ...

Recommend

  • Fatal Python error: Py_Initialize: can't initialize sys standard streams LookupError: unknown e
  • Python C extension: Extract parameter from the engine
  • Yii2 Login with database
  • Submit a form with jQuery / Javascript without ignoring “required” tag
  • Granting permissions to Azure Active Directory Web Application automatically
  • Many to Many in Linq using Dapper
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Backward compatibility of Python 3.5 for external modules
  • How to validate a year I enter in textbox using jquery rule?
  • Laravel at least one field is required
  • LiveData is abstract android
  • Implement JwtBearer Authentication in NSwag SwaggerUi
  • Sensibility of combined Maven/Ant+Ivy build management for dual platform Desktop/Android deployment?
  • npm 5.4.1 install/uninstall all failing
  • Validate child input components on submit with Vee-Validate and vue js 2
  • Does Mobilefirst provide a provision to access web services directly?
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • azure media services - The request body is too large and exceeds the maximum permissible limit
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • Xamarin Forms - UWP Fonts
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Running a C# exe file
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Adding custom controls to a full screen movie
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • Arrays break string types in Julia
  • Python: how to group similar lists together in a list of lists?
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • How does Linux kernel interrupt the application?
  • Qt: Run a script BEFORE make
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • Does armcc optimizes non-volatile variables with -O0?
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory
  • How can i traverse a binary tree from right to left in java?
  • Why do underscore prefixed variables exist?