python - Python 路径问题。 "ImportError: No module named setuptools"

标签 python django

我最近更新到了 Python 2.7,以便开始使用 Django "Django requires Python, specifically Python 2.6.5 - 2.7.x."

因此,我需要安装一些我在经历出色的 LPTHW Exercise 46 时一直在使用的工具。

  1. pip from http://pypi.python.org/pypi/pip
  2. distribute from http://pypi.python.org/pypi/distribute
  3. nose from http://pypi.python.org/pypi/nose/
  4. virtualenv from http://pypi.python.org/pypi/virtualenv

应该很容易,我以前已经完成了......

当我在终端中运行 python 时,我得到以下内容。 注意:Python 2.7.5

$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

当我输入“which python”时,我得到

$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

但是,当我尝试安装 distribution、nose 或 virtualenv 时,出现以下错误。 注意Python/2.6

$ sudo pip install distribute
Exception:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/pip-1.3.1-py2.6.egg/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/Library/Python/2.6/site-packages/pip-1.3.1-py2.6.egg/pip/commands/install.py", line 258, in run
import setuptools
ImportError: No module named setuptools

Storing complete log in /Users/brendanspillane/Library/Logs/pip.log
localhost:~ brendanspillane$ 

我相信 Python/2.6 是这里的问题。结果我尝试设置我的Python路径(我第一次)使用这个问题作为引用"changing python path on mac?"我输入了

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" 
export PATH

这没有明显的效果。

但是我仍然无法运行 sudo pip install distribution 并不断收到相同的错误。

有人可以帮助我吗?这是我的Python路径吗?还是我看错了方向?

一如既往,非常感谢任何帮助。

深化

最佳答案

我不太确定它是如何工作的,但确实如此。 @Robert Lujo 的回答值得投赞成票 https://stackoverflow.com/a/16511140/1214163

如果答案也添加在这里,我会接受。

关于python - Python 路径问题。 "ImportError: No module named setuptools",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16846742/

相关文章:

python - Python Fabric 任务可以调用其他任务并尊重它们的主机列表吗?

Python用子串排序字符串数组

python - Django:无法迁移从源代码安装的应用程序

python - 有没有一种简单、优雅的方式来定义单例?

Django - 过滤器(__icontains)不起作用

python - Django session 意外丢失数据

django - 如何在Django中建立Gmail样式搜寻?

python - Django 导入-导出 : IntegrittyError when trying to insert duplicate record in field(s) with unique or unique_together constraints

python - 使用 PyPDF2 批量旋转 PDF 文件

python - 我无法安装 mysqlclient