为 pip 格式化一个 requirements.txt 文件,其中一个或多个包具有不同的索引 - url
Format a requirements.txt file for pip where one or more packages have a different index-url
我正在尝试将 Django 应用程序部署到 Heroku,其中一个必需的包位于 https://testpypi.python.org/pypi
上,当然 Django 在主 PyPI 服务器上。
requirements.txt
文件如下所示:
Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4
运行 pip install -r requirements.txt
失败并出现以下错误:
Could not find any downloads that satisfy the requirement Django==1.7.7 (from -r requirements.txt (line 1))
Cleaning up...
No distributions at all found for Django==1.7.7 (from -r requirements.txt (line 1))
看起来 pip
正试图在 testpypi
上寻找 Django
所以我尝试了这个:
-i https://pypi.python.org/pypi/
Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4
它导致同样的错误。
如果我只在需求文件中放置一个(无关紧要 一个)包,pip 能够找到并安装该包。
问题:在命令pip install -r file
[=可以读取的单个文件中指定多个不同的index-url
参数的正确语法是什么24=]
我认为这不重要,但 python 是 3.4.0 版,pip 是 pip 1.5.2
版。
我已将 pip 更新到版本 6.0.8,错误现在显示为:
Could not find any downloads that satisfy the requirement Django==1.7.7 (from -r requirements.txt (line 2))
No distributions at all found for Django==1.7.7 (from -r requirements.txt (line 2))
根据定义,任何私有索引定义都将应用于每个包
https://devcenter.heroku.com/articles/python-pip#private-indexes
All dependencies specified in that requirements file will resolve against that index.
作为解决方法,您可以创建多个需求文件并将它们级联:
https://devcenter.heroku.com/articles/python-pip#cascading-requirements-files
If you would like to utilize multiple requirements files in your codebase, you can include the contents of another requirements file with pip:
-r ./path/to/prod-requirements.txt
Update:原来处理私有索引的正确方法是使用--extra-index-url
开关。来自 documentation of pip:
Note that using --index-url removes the use of PyPI, while using --extra-index-url will add additional indexes.
所以,放行
--extra-index-url https://testpypi.python.org/pypi
在你的 requirements.txt
之上应该足够了。完全不需要级联!
我正在尝试将 Django 应用程序部署到 Heroku,其中一个必需的包位于 https://testpypi.python.org/pypi
上,当然 Django 在主 PyPI 服务器上。
requirements.txt
文件如下所示:
Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4
运行 pip install -r requirements.txt
失败并出现以下错误:
Could not find any downloads that satisfy the requirement Django==1.7.7 (from -r requirements.txt (line 1))
Cleaning up...
No distributions at all found for Django==1.7.7 (from -r requirements.txt (line 1))
看起来 pip
正试图在 testpypi
所以我尝试了这个:
-i https://pypi.python.org/pypi/
Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4
它导致同样的错误。
如果我只在需求文件中放置一个(无关紧要 一个)包,pip 能够找到并安装该包。
问题:在命令pip install -r file
[=可以读取的单个文件中指定多个不同的index-url
参数的正确语法是什么24=]
我认为这不重要,但 python 是 3.4.0 版,pip 是 pip 1.5.2
版。
我已将 pip 更新到版本 6.0.8,错误现在显示为:
Could not find any downloads that satisfy the requirement Django==1.7.7 (from -r requirements.txt (line 2))
No distributions at all found for Django==1.7.7 (from -r requirements.txt (line 2))
根据定义,任何私有索引定义都将应用于每个包
https://devcenter.heroku.com/articles/python-pip#private-indexes
All dependencies specified in that requirements file will resolve against that index.
作为解决方法,您可以创建多个需求文件并将它们级联:
https://devcenter.heroku.com/articles/python-pip#cascading-requirements-files
If you would like to utilize multiple requirements files in your codebase, you can include the contents of another requirements file with pip:
-r ./path/to/prod-requirements.txt
Update:原来处理私有索引的正确方法是使用--extra-index-url
开关。来自 documentation of pip:
Note that using --index-url removes the use of PyPI, while using --extra-index-url will add additional indexes.
所以,放行
--extra-index-url https://testpypi.python.org/pypi
在你的 requirements.txt
之上应该足够了。完全不需要级联!