4

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
2
  • Is the structure to the Libs directory still intact when you unzip? This is needed for it to find all the system libraries. Commented Oct 11, 2010 at 7:53
  • it is exactly like in the zip, and compared to CPython it's much smaller Commented Oct 11, 2010 at 8:07

2 Answers 2

5

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 the CPython Lib directory. 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.

Sign up to request clarification or add additional context in comments.

3 Comments

but won't this conflict runtimes ? if any installed python library from Lib has C or C++ modules ?
Mmmh... I'm not sure, but probably some modules won't work if they depend on C or C++...
This worked for me. On OSX I did export IRONPYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
1

This must help:

import sys
sys.path.append("C:\\PythonXY\\Lib")

1 Comment

Try to add more about why this will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.