从requirements.txt安装python pip麻烦
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28167987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
python pip trouble installing from requirements.txt
提问by deltaskelta
I've had great luck with pip in the past, but working at installing some stuff in a venv on is giving me some headaches. I keep getting errors like No distributions at all found for somepackage Storing debug log for failure in /root/.pip/pip.log
过去我在 pip 上很幸运,但是在 venv 上安装一些东西让我有些头疼。我不断收到一些错误,例如根本找不到某些软件包的发行版在 /root/.pip/pip.log 中存储失败的调试日志
Could not find any downloads that satisfy the requirement somepackage
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-RjqjFW/psycopg2
I know these packages are installed on the main system, but its like they won't work on the venv. How do you all get around this problem? It's been a long day and I just don't understand what the problem is, especially because they work on my local system, they work on the main python install on my remote system, but not in the venv for some crazy reason. Any ideas?
我知道这些软件包安装在主系统上,但好像它们在 venv 上不起作用。大家都是怎么解决这个问题的?这是漫长的一天,我只是不明白问题是什么,特别是因为它们在我的本地系统上工作,它们在我的远程系统上的主要 python 安装上工作,但由于某些疯狂的原因不在 venv 中。有任何想法吗?
Here is the requirements, I thought it was alittle intense for django, but thats what pip freeze > requirements.txt gave me
这是要求,我认为 django 有点紧张,但这就是 pip freeze > requirements.txt 给我的
Babel==1.3
Django==1.7.1
Fabric==1.10.1
Flask==0.10.1
Flask-Babel==0.9
Flask-Login==0.2.11
Flask-Mail==0.9.1
Flask-OpenID==1.2.4
Flask-SQLAlchemy==2.0
Flask-WTF==0.10.3
Flask-WhooshAlchemy==0.56
Jinja2==2.7.3
MarkupSafe==0.23
PAM==0.4.2
Pillow==2.3.0
Pygments==1.6
Scrapy==0.24.4
Sphinx==1.2.2
Tempita==0.5.2
WTForms==2.0.1
Werkzeug==0.9.6
Whoosh==2.6.0
adium-theme-ubuntu==0.3.4
apt-xapian-index==0.45
argparse==1.2.1
backports.ssl-match-hostname==3.4.0.2
blinker==1.3
boto==2.20.1
bottle==0.12.7
certifi==14.05.14
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
coverage==3.7.1
cssselect==0.9.1
debtagshw==0.1
decorator==3.4.0
defer==1.0.6
dirspec==13.10
docutils==0.11
duplicity==0.6.23
ecdsa==0.11
flipflop==1.0
guess-language==0.2
guppy==0.1.9
html5lib==0.999
httplib2==0.8
ipython==2.3.1
itsdangerous==0.24
lockfile==0.8
lxml==3.3.3
nose==1.3.4
numpy==1.8.2
oauthlib==0.6.1
oneconf==0.3.7
paramiko==1.15.2
pbr==0.10.7
pexpect==3.1
piston-mini-client==0.7.5
psycopg2==2.5.4
pyOpenSSL==0.13
pyasn1==0.1.7
pycrypto==2.6.1
pycups==1.9.66
pycurl==7.19.3
pygame==1.9.1release
pygobject==3.12.0
pyserial==2.6
pysmbc==1.0.14.1
python-apt==0.9.3.5ubuntu1
python-debian==0.1.21-nmu2ubuntu2
python-openid==2.2.5
pytz==2014.10
pyxdg==0.25
queuelib==1.2.2
reportlab==3.0
requests==2.2.1
roman==2.0.0
sessioninstaller==0.0.0
simplegeneric==0.8.1
six==1.5.2
software-center-aptd-plugins==0.0.0
speaklater==1.3
sqlalchemy-migrate==0.9.2
sqlparse==0.1.14
system-service==0.1.6
tornado==4.0.2
unity-lens-photos==1.0
urllib3==1.7.1
virtualenv==1.11.6
w3lib==1.10.0
wsgiref==0.1.2
wxPython==2.8.12.1
wxPython-common==2.8.12.1
xdiagnose==3.6.3build2
z3c.xmlhttp==0.5.1
zope.interface==4.0.5
zope.publisher==4.0.0a4
zope.traversing==4.0.0
zope.viewlet==4.0.0a1
采纳答案by Burhan Khalid
I see a few problems:
我看到几个问题:
Your
requirements.txt
is for the base system Python, not any virtual environment. Django does not have any external dependencies.You are using the root user to install packages in your virtual environment (or you are using
sudo
when you shouldn't).
您
requirements.txt
是针对基本系统 Python 的,而不是任何虚拟环境。Django 没有任何外部依赖项。您正在使用 root 用户在您的虚拟环境中安装软件包(或者您
sudo
在不应该使用的情况下使用)。
The best option is to start from scratch:
最好的选择是从头开始:
$ virtualenv myvenv
...
$ source myvenv/bin/activate
(myvenv) $ pip install django
...
(myvenv) $ pip freeze > requirements.txt
回答by Nii Mantse
Had a similar issue but the above method didn't work for me. Clarified it with a rather simpler solution:
有类似的问题,但上述方法对我不起作用。用一个相当简单的解决方案澄清它:
(venv) $ pip install --upgrade -r requirements.txt
(venv) $ pip install --upgrade -r requirements.txt
UPDATE:This command upgrades all packages that have been explicitly listed in your requirements.txt
file.
更新:此命令升级requirements.txt
文件中明确列出的所有软件包。
Your requirements.txt
file is just a list of pip install arguments placed in a file. They are used to hold the result from pip freeze for the purpose of achieving repeatable installations. In this case, your requirements.txt
file contains a pinned version of everything that was installed when pip freeze was run.
您的requirements.txt
文件只是放置在文件中的 pip install 参数列表。它们用于保存 pip freeze 的结果,以实现可重复安装。在这种情况下,您的requirements.txt
文件包含运行 pip freeze 时安装的所有内容的固定版本。
回答by chasmani
I had this problem but with a different cause - I had an old version of virtualenv. Before version 1.7 you had to specify the option --no-site-packages when you create the virtual environment to not include global packages.
我遇到了这个问题,但有一个不同的原因 - 我有一个旧版本的 virtualenv。在 1.7 版之前,您必须在创建虚拟环境以不包含全局包时指定选项 --no-site-packages。
Two options to fix this, either upgrade your virtualenv:
解决此问题的两个选项,要么升级您的 virtualenv:
sudo pip install virtualenv --upgrade
virtualenv venv
Or use the old one with the no-site-packages option:
或者使用带有 no-site-packages 选项的旧版本:
virtualenv venv --no-site-packages
That fixed my requirements.txt file.
这修复了我的 requirements.txt 文件。
回答by abhishek thakur
try pip install -r requirements.txt
尝试 pip install -r requirements.txt
It worked for me
它对我有用
回答by Juba Fourali
sudo pip install -r requirements.txt
orpip install -r requirements.txt
worked for me
sudo pip install -r requirements.txt
或pip install -r requirements.txt
为我工作
回答by Syeda Ruqhaiya Fatima
Following solution has worked for me :
以下解决方案对我有用:
(my-virtualenv) 20:42 ~/MyPf (master)$ pip freeze > requirements.txt |
(my-virtualenv) 20:43 ~/MyPf (master)$ pip install -r requirements.txt