简体   繁体   中英

Python-Django: ImportError: no module named django

Im completely new to django and Ive been trying to set up an environment from here [ https://docs.djangoproject.com/en/1.1/intro/tutorial01/] . Python was already setup on my mac Python 2.7.2 . I followed the instructions and setup django using

sudo port install py27-django

And also added /etc/paths.d/macports with

/opt/local/bin
/opt/local/sbin
/opt/local/lib/python2.7/site-packages/django/bin

But I still get the ImportError: No module named django message when I import django from the python shell. I looked at this link importerror: No module named django but it didnt really help much. Any help is appreciated

如果可以的话,看来您添加的最后一个路径指向python2.4目录,您可能需要在python2.7目录中寻找django

Have a look at this article... they are using virtualenv to set up the project and this fixed a lot of problems like this for me. With virtualenv, the system libraries and the libraries you need for your python project are separated, so your not mangling them together.

http://www.jeffknupp.com/blog/2012/02/09/starting-a-django-project-the-right-way/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM