Today I was trying to run nose on some tests, but keeping getting this error:
'import site' failed; use -v for traceback
At first I doubted that the problem was derived from two different versions of Python. A few days ago I downloaded and built python2.7 which is still in the trunk. When I built it, I forgot to specify the tag --prefix. So, python2.7 was installed into /usr/local/, and the python command was directed to python2.7. However, when I built nose, it was extracted into /usr/lib/python2.5/site-packages/. Thus, nose kept giving me the error above. So, I removed python2.7 (this step took me a long time because I was not familiar with the locations where python2.7 was installed.). Guess what, I still could not run nose. I tried "python -V" to get the current version, and found that the current version was still python2.7. It turned out that I forgot to delete the binary file "python" under /usr/local/bin/. OK, I directly copy the binary file under /usr/bin/ to overwrite the one in /usr/local/bin/. And still, nose did not work. I got nearly crazy and came near to reinstall the operating system. Finally, I added two lines into .bashrc file:
PYTHONPATH="/usr/lib/python2.5"
PYTHONHOME="/usr/lib/python2.5"
and then rebooted the operating system (I tried source command but nose still could not work.). Thank God! Everything works fine now.

0 comments

Post a Comment