【问题标题】:NameError: name 'install' is not defined when installing packages using pipNameError:使用 pip 安装软件包时未定义名称“安装”
【发布时间】:2014-05-13 08:25:51
【问题描述】:

我正在尝试使用 pip 创建 virtualenv 并安装项目依赖项。

$ mkvirtualenv --no-site-packages --distribute myenv
(myenv)$ pip install -r requirements.txt

我还在~/.bash_profile中设置了export VIRTUALENV_DISTRIBUTE=true

安装一些软件包后 pip 显示以下错误:

.....

Could not find the /Users/me/.virtualenvs/myenv/lib/python2.7/site-packages/site.py element of the Setuptools distribution

Patched done.

Relaunching...

Traceback (most recent call last):

  File "<string>", line 1, in <module>

NameError: name 'install' is not defined

----------------------------------------
Cleaning up...
Command /Users/me/.virtualenvs/myenv/bin/python -c "import setuptools;__file__='/Users/me/.virtualenvs/myenv/build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/r0/2b441j6x5rq8y964bhd15gkm0000gn/T/pip-wyn1Ys-record/install-record.txt --single-version-externally-managed --install-headers /Users/me/.virtualenvs/myenv/include/site/python2.7 failed with error code 1 in /Users/me/.virtualenvs/myenv/build/distribute

没有--distribute 开关和没有export VIRTUALENV_DISTRIBUTE=true 的情况完全相同

这是我的 requirements.txt 文件:

Django==1.5
Pillow==1.7.6
South==0.7.3
amqplib==1.0.2
anyjson==0.3.1
celery==2.5.3
distribute==0.6.10
django-celery==2.4.2
django-indexer==0.3.0
django-kombu==0.9.4
django-mptt==0.5.2
django-paging==0.2.4
django-picklefield==0.2.1
django-social-auth==0.7.22
django-tagging==0.3.1
django-taggit==0.9.3
django-templated-email==0.4.7
django-templatetag-sugar==0.1
eventlet==0.9.16
greatape==0.3.0
greenlet==0.3.4
html5lib==0.90
httplib2==0.8
kombu==2.1.7
lockfile==0.9.1
oauth2==1.5.211
pycrypto==2.3
python-daemon==1.6
python-dateutil==1.5
python-openid==2.2.5
raven==1.0.4
sentry==2.0.0-RC6
simplejson==2.3.2
ssh==1.7.8
wsgiref==0.1.2

我正在使用Mac OS X 10.9.2。 我不想更改 requirements.txt 中的任何内容,我只想安装所有依赖项并运行此项目。

【问题讨论】:

  • 在哪个包裹上摔倒了?有趣的是,distribute 是必需的包之一。
  • Distribute 包上失败
  • 您在.bashrc 中设置了VIRTUALENV_DISTRIBUTE,但您是否获取了.bashrc 的来源?否则,该变量不会在您当前的 shell 中设置。
  • 我在.bash_profile 中设置了这个变量并打开了新的终端...source .bashrc 是什么意思?
  • 阅读askubuntu.com/questions/121073/…,尤其是接受的答案。

标签: python python-2.7 pip virtualenv virtualenvwrapper


【解决方案1】:

从列表中删除distribute 包,重新创建您的环境并重新安装要求。

您也可以删除wsgiref(虽然不是很重要)。

【讨论】:

  • 请解释为什么安装 'distribute' 会导致错误,因为它可能对即将到来的网站访问者有所帮助。
  • pythonhosted.org/distribute """ Distribute 是 Setuptools 项目的已弃用分支。自 Setuptools 0.7 版本以来,Setuptools 和 Distribute 已合并,不再维护 Distribute。所有正在进行的工作都应参考 Setuptools项目和 Setuptools 文档。"""
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-01-18
  • 2016-09-23
  • 2019-04-21
  • 2018-06-25
  • 1970-01-01
  • 2020-05-19
  • 2021-09-16
相关资源
最近更新 更多