我正在运行Mac OS X 10.8.5,并尝试从ZIP安装Django。我下载了Django ZIP并运行了安装程序:
RYAN-1970:~ jamesryan$ /Users/jamesryan/Downloads/django-django-597ab3c/INSTALL ; exit;
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 1: Thanks: command not found
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 3: To: command not found
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 4: this: command not found
python: can't open file 'setup.py': [Errno 2] No such file or directory
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 10: If: command not found
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 11: site-packages: command not found
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 12: lives.: command not found
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 14: syntax error near unexpected token `Unix,'
/Users/jamesryan/Downloads/django-django-597ab3c/INSTALL: line 14: ` /usr/lib/python2.7/site-packages (Unix, Python 2.7)'
logout
[Process completed]
但是当我尝试导入Django时:
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
然后我根据我的搜索尝试了这个:
>>> import sys
>>> sys.path
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']
>>>
首先我尝试使用pip,但发生了这种情况:
>>> get-pip.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'get' is not defined
有人有任何建议吗?
答案 0 :(得分:1)
INSTALL
是一套描述如何安装Django的英语说明。 不是安装程序。而不是尝试用shell执行它,阅读它们并遵循内部的指示。
至于为什么get-pip.py
失败,你打开了一个Python shell,并为Python提示符提供了文件名get-pip.py
。但是Python REPL并没有采用文件名;它需要Python表达式。它以为您尝试检索变量get
并减去py
对象的属性pip
。但get
和pip
都不存在,所以你得到NameError
。
如果你想安装pip,请使用普通的shell(比如Bash),然后运行python get-pip.py
。
答案 1 :(得分:0)
试试这个:
sudo python setup.py install
答案 2 :(得分:0)
First time install Django on Mac OSX Mountain Lion
感谢你的帮助,这很糟糕。