我在安装 Django 时遇到问题。似乎Python一旦安装就无法识别它。以下是我已采取的步骤。我正在使用 Mac OS 10.7.5 Python 2.7 和 Django 1.5.1
我没有使用 virtualenv
我究竟做错了什么?Python 不能识别它有什么原因吗?我怎样才能解决这个问题?
这是我所做的:
卸载它,(用pip)
Successfully uninstalled Django
检查是否已卸载(通过蛋黄)
localhost:mysite brendan$ yolk -l
Flask-SQLAlchemy - 0.16 - active
Flask - 0.10.1 - active
Jinja2 - 2.7 - active
MarkupSafe - 0.18 - active
Python - 2.7 - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload)
SQLAlchemy - 0.8.2 - active
Werkzeug - 0.9.1 - active
boto - 2.9.7 - active
itsdangerous - 0.22 - active
nose - 1.3.0 - active
pip - 1.3.1 - active
setuptools - 0.8 - active
tweepy - 1.7.1 - non-active
tweepy - 1.9 - active
virtualenv - 1.9.1 - active
wsgiref - 0.1.2 - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7)
yolk - 0.4.3 - active
安装它,(用pip)
localhost:mysite brendan$ pip install django
Downloading/unpacking django
Downloading Django-1.5.1.tar.gz (8.0MB): 8.0MB downloaded
Running setup.py egg_info for package django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.7/django-admin.py from 644 to 755
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
changing mode of /Library/Frameworks/Python.framework/Versions/2.7/bin/django-admin.py to 755
Successfully installed django
Cleaning up...
localhost:mysite brendan$ python
Python 2.7.5 (default, May 19 2013, 13:26:47)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
尝试导入时出现此错误:
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
>>>
编辑/更新:
哪个点
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
哪条蟒蛇
/opt/local/bin/python
我没有使用 virtualenv