Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

python - Importing Libraries Issue - "ImportError: No Module named ____"

I've looked through a lot of the other question/answers for this topic but no avail.

I downloaded numpy and nltk using pip, and based on the messages I know the install location is: Requirement already satisfied (use --upgrade to upgrade): nltk in /usr/local/lib/python2.7/site-packages, so it looks like it's installing in the directory for version 2.7.

When I run python I get Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43), so that's clearly also version 2.7.

However, when I try "import nltk" or "import numpy" in the Python console, I always get the ImportError: No module named nltk error. Any advice would be greatly appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try changing the PYTHONPATHenvironment variable. If you are using BASH the below should work. Other Linux shells will be slightly different in how they assign environment variables.

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...