Mac OSX:安装Django后出错 - 没有名为django的模块

时间:2014-02-15 02:42:15

标签: python django

我使用的是MacOS X 10.7.5,并且是Python的全新内容

我非常确定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

1 个答案:

答案 0 :(得分:0)

问题在于先前安装了Python(2.7.1)并且MacPorts安装了新的(2.7.6)但没有更新Mac Sym链接等

所以我不得不使用我的PATH

$ 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