1

It seems strange that a module from the std Python lib to be missing. I'm probably doing something wrong, but I cannot figure out what exactly.

shift@bt:~/experiments/$ python test/test_creation.py 
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "test/test_creation.py", line 1, in <module>
    import unittest
ImportError: No module named unittest

Running with the -v switch shows this:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "test/test_creation.py", line 1, in <module>
    import unittest
ImportError: No module named unittest
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# clear sys.flags
# clear sys.float_info
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] signal
# cleanup[1] exceptions
# cleanup[1] _warnings
# cleanup sys
# cleanup __builtin__
# cleanup ints: 3 unfreed ints
# cleanup floats

Where should I look to figure out what's wrong?

11
  • 1. Does your script fiddle around with sys.path? 2. What's the output of env | grep PYTHON? 3. Does import unittest work in the interactive interpreter? Commented Jun 11, 2011 at 22:10
  • 1. No. 2. PYTHONHOME=/home/shift/experiments/lib 3. No. Commented Jun 11, 2011 at 22:12
  • perhaps a stupid question, but you don't have some bogus character in your .py file after "unittest"? Does it work from idle or when just starting pyton and typing "import unittest"? Commented Jun 11, 2011 at 22:14
  • check where your PYTHONHOME is set to, ops didnt see the comment. well, now you know where to look. that env is messing things up :) Commented Jun 11, 2011 at 22:15
  • @Fredrik, it doesn't work from the interactive interpreter either. @ashwoods, my PYTHONHOME is set to /home/shift/experiments/lib, the same folder as the test folder is in, though I didn't set it manually. Commented Jun 11, 2011 at 22:17

1 Answer 1

1

You have your python environment installed into /home/shift/experiments/lib ? see docs.python.org on PYTHONHOME

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

1 Comment

No, it somehow got set to that value, and from there on, all hell broke loose.

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.