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!

Was it helpful?

Solution

From the looks of the source code, 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 might work is to create a symbolic link to the directory somewhere where there isn't a : in the path name and use that instead ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top