0

我只是无法在我的 Mac 上安装 django:/

这里:brew卸载python,brew install python,pip install django,python,import django

nma-2:~ nikolaialeksandrenko$ brew uninstall python
Error: No such keg: /usr/local/Cellar/python
nma-2:~ nikolaialeksandrenko$ brew install python
Warning: You have not agreed to the Xcode license.
Builds will fail! Agree to the license by opening Xcode.app or running:
    xcodebuild -license
==> Downloading http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tar.bz2
Already downloaded: /Library/Caches/Homebrew/python-2.7.4.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python/2.7.4 --enable-ipv6 --datarootdir=/usr/local/Cellar/python/2.7.4/share --datadir=/usr/local/Cellar
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.4
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.4/share/python
==> Downloading https://pypi.python.org/packages/source/d/distribute/distribute-0.6.38.tar.gz
Already downloaded: /Library/Caches/Homebrew/distribute-0.6.38.tar.gz
==> /usr/local/Cellar/python/2.7.4/bin/python -s setup.py --no-user-cfg install --force --verbose --install-lib=/usr/local/Cellar/python/2.7.4/Frame
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/pip-1.3.1.tar.gz
==> /usr/local/Cellar/python/2.7.4/bin/python -s setup.py --no-user-cfg install --force --verbose --install-lib=/usr/local/Cellar/python/2.7.4/Frame
==> Caveats
Homebrew's Python framework
  /usr/local/Cellar/python/2.7.4/Frameworks/Python.framework

Python demo
  /usr/local/share/python/Extras

Distribute and Pip have been installed. To update them
  pip install --upgrade distribute
  pip install --upgrade pip

To symlink "Idle" and the "Python Launcher" to ~/Applications
  `brew linkapps`

You can install Python packages with (the outdated easy_install or)
  `pip install <your_favorite_package>`

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

Executable python scripts will be put in:
  /usr/local/share/python
so you may want to put "/usr/local/share/python" in your PATH, too.

See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
==> Summary
  /usr/local/Cellar/python/2.7.4: 5195 files, 80M, built in 102 seconds
nma-2:~ nikolaialeksandrenko$ brew link python
Warning: Already linked: /usr/local/Cellar/python/2.7.4
To relink: brew unlink python && brew link python
nma-2:~ nikolaialeksandrenko$ pip install Django
Requirement already satisfied (use --upgrade to upgrade): Django in /usr/local/lib/python2.7/site-packages
Cleaning up...
nma-2:~ nikolaialeksandrenko$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 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
>>> import Django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Django
>>> 
4

2 回答 2

0

链接不起作用。您链接到(或尝试链接到)的是 python 2.7.4,但是当您运行它时,python它清楚地显示“Python 2.7.2”。

尝试在 python 中运行它:

import site; site.getsitepackages()

它应该向您显示site-packages与您正在运行的 python 版本关联的目录的位置。要尝试的另一件事是运行which python以查看您实际调用的可执行文件。

如果结果不正确(将其与 django 安装目录进行比较),您应该手动将其他 python 目录添加到您的路径中。把它放在你.profile的主目录中的文件中:

PATH="/usr/local/Cellar/python/2.7.4/bin/:$PATH"

这确保了新安装的 Homebrew 特定的 python 是在没有任何路径的情况下运行它时执行的——这应该与pip正在使用的可执行文件匹配。

于 2013-10-01T12:47:42.687 回答
0

你可以在这里下载 Django 。在 macos 上安装 django 的默认步骤可以在这里找到。

tar xzvf Django-1.5.4.tar.gz
cd Django-1.5.4
sudo python setup.py install
于 2013-10-01T12:38:10.273 回答