开发者

Configuring Python 2.7 to use modules

I installed Python 2.7, OpenCV2.2, Numpy 1.51, SCIPY 0.9.0 and PIL 1.1.7 on a Windows 32-bit system. Everything works fine (i.e. I can import modules) when Python is called from the directory it is inst开发者_如何学Goalled in (i.e. C:\Program Files\Python27). However, I cannot load modules (e.g. ImportError: No module named PIL) if I Python is started from any other directory. My System variables are as follows:

PATH= ...;;C:\Program Files\Python27;C:\Program Files\OpenCV2.2\bin PYTHONPATH=C:\Program Files\Python27\Lib\site-packages;C:\Program Files\OpenCV2.2\Python2.7\Lib\site-packages

What am I missing?


You should set the PYTHONPATH environment variable.
http://docs.python.org/using/cmdline.html#envvar-PYTHONPATH

For some reason on my Linux system, this variable isn't set. But if I go into the Python shell and run:

import sys
print sys.path

it shows the location of all my modules.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜