[英]IronPython cannot import module 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. 所以我有一个基本的ZIPPED IronPython(2.6或2.6.1),我只需解压缩,启动ipy.exe,输入“import os”并点击回车。 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. 即使我先导入clr,它也不起作用。 What's it to be done ?
怎么办?
I've googled this issue but no relevant answer. 我用Google搜索了这个问题,但没有相关的答案。 The closest idea was this (which didn't work):
最接近的想法是这个(它不起作用):
import clr
clr.AddReference("IronPython")
clr.AddReference("IronPython.Modules")
import os
Likely, the problem is not the in zip, but in os module location. 可能,问题不在于zip,而是在os模块位置。
You need to have CPython
installed and your script should be able to reach the CPython Lib
directory. 您需要安装
CPython
并且您的脚本应该能够访问CPython Lib
目录。 To get this you can either copy all the os necessary files under your Lib
directory, or you can set the environment variable IRONPYTHONPATH
to point to the Lib
directory below CPython
. 为此,您可以复制
Lib
目录下的所有os必需文件,也可以将环境变量IRONPYTHONPATH
设置为指向CPython
下面的Lib
目录。
This must help: 这必须有所帮助:
import sys
sys.path.append("C:\\PythonXY\\Lib")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.