2014-02-15 48 views
0

我使用的MacOS X 10.7.5和我共福利局在Python的Mac OSX上:安裝後Django的錯誤 - 沒有命名的Django模塊

我正確安裝非常肯定的Django按照https://code.djangoproject.com/wiki/Distributions

$ sudo port install py27-django 
---> Computing dependencies for py27-django 
---> Cleaning py27-django 
---> Scanning binaries for linking errors: 100.0% 
---> No broken files found. 
$ python 
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] 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 

回答

0

的問題是與已安裝的Python之前(2.7.1)以前的MacPorts和安裝一個新的(2.7.6),但沒有更新了Mac符號鏈接等

所以我和我的PATH

到futz
$ vi ~/.bash_profile 
. 
. 
export PATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH 
. 
. 
$ source ~/.bash_profile 
$ python --version 
Python 2.7.6 
$ python 
Python 2.7.6 (default, Nov 12 2013, 13:12:10) 
[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 
>>> print django.get_version() 
1.5.1 
+1

我建議你使用virtualenv(http://www.virtualenv.org/en/latest/)來隔離你的項目的依賴關係,而不必混淆整個系統的包。 – kirbuchi

相關問題