如何根据本地目录中的requirements.txt文件使用pip安装软件包? [英] How to install packages using pip according to the requirements.txt file from a local directory?
问题描述
这是问题
我有一个require.txt,看起来像:
I have a requirements.txt that looks like:
BeautifulSoup==3.2.0
Django==1.3
Fabric==1.2.0
Jinja2==2.5.5
PyYAML==3.09
Pygments==1.4
SQLAlchemy==0.7.1
South==0.7.3
amqplib==0.6.1
anyjson==0.3
...
我有一个本地存档目录,其中包含所有软件包和其他软件包.
I have a local archive directory containing all the packages + others.
我创建了一个新的virtualenv
I have created a new virtualenv with
bin/virtualenv testing
在激活它后,我尝试根据本地存档目录中的requirements.txt安装软件包.
upon activating it, I tried to install the packages according to requirements.txt from the local archive directory.
source bin/activate
pip install -r /path/to/requirements.txt -f file:///path/to/archive/
我得到一些输出,似乎表明安装正常
I got some output that seems to indicate that the installation is fine
Downloading/unpacking Fabric==1.2.0 (from -r ../testing/requirements.txt (line 3))
Running setup.py egg_info for package Fabric
warning: no previously-included files matching '*' found under directory 'docs/_build'
warning: no files found matching 'fabfile.py'
Downloading/unpacking South==0.7.3 (from -r ../testing/requirements.txt (line 8))
Running setup.py egg_info for package South
....
但是后来检查发现没有正确安装该软件包.我无法导入软件包,但在virtualenv的site-packages目录中找不到任何软件包.那么出了什么问题?
But later check revealed none of the package is installed properly. I cannot import the package, and none is found in the site-packages directory of my virtualenv. So what went wrong?
推荐答案
这对我有用:
$ pip install -r requirements.txt --no-index --find-links file:///tmp/packages
--no-index
-忽略软件包索引(仅查看--find-links
URL).
--no-index
- Ignore package index (only looking at --find-links
URLs instead).
-f, --find-links <URL>
-如果是URL或html文件的路径,则解析到存档的链接.
如果这是目录的本地路径或file://
URL,请在目录列表中查找档案.
-f, --find-links <URL>
- If a URL or path to an html file, then parse for links to archives.
If a local path or file://
URL that's a directory, then look for archives in the directory listing.
这篇关于如何根据本地目录中的requirements.txt文件使用pip安装软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!