本文介绍了Python3.3 - 致命的Python错误:Py_Initialize:无法获取区域设置编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ImportError:没有名为'编码'的模块

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(/ path / with :冒号/);

然后调用:

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?

谢谢!

推荐答案

的外观,没有办法要做到这一点,我可以看到...

From the looks of the source code, there is no way to do this that I can see...

Py_SetPath 只需清除以前可能设置的任何路径然后将其重置为您没有真正处理的字符串。这是通过 Py_GetPath 返回的,所有这一切都是我想的。

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 ...

这篇关于Python3.3 - 致命的Python错误:Py_Initialize:无法获取区域设置编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 10:30