IronPython 无法导入模块操作系统
所以我有一个基本的 ZIPPED IronPython(2.6 或 2.6.1),我只需解压缩,启动 ipy.exe,输入“import os”并按 Enter 键。 出现以下输出:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named os
即使我先导入 clr,它也不起作用。要做什么呢?
我用谷歌搜索过这个问题,但没有相关答案。最接近的想法是这个(但不起作用):
import clr
clr.AddReference("IronPython")
clr.AddReference("IronPython.Modules")
import os
So I have a basic ZIPPED IronPython (2.6 or 2.6.1) that I just unzip, start ipy.exe, type "import os" and hit enter.
The following output happens:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named os
It doesn't work even if I import clr first. What's it to be done ?
I've googled this issue but no relevant answer. The closest idea was this (which didn't work):
import clr
clr.AddReference("IronPython")
clr.AddReference("IronPython.Modules")
import os
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题可能不是 zip 中的问题,而是操作系统模块位置中的问题。
您需要安装
CPython
并且您的脚本应该能够到达CPython Lib
目录。为此,您可以将所有操作系统必需的文件复制到Lib
目录下,也可以将环境变量IRONPYTHONPATH
设置为指向Lib
>CPython
下的目录。Likely, the problem is not the in zip, but in os module location.
You need to have
CPython
installed and your script should be able to reach theCPython Lib
directory. To get this you can either copy all the os necessary files under yourLib
directory, or you can set the environment variableIRONPYTHONPATH
to point to theLib
directory belowCPython
.这一定有帮助:
This must help: