pip没有从requirements.txt安装软件包,而是从命令安装了

时间:2020-02-15 16:57:49

标签: python pip

我有两个与需求有关的文件。呼叫时出现此错误:

$ pip install -r requirements.txt --no-index --find-links file:///tmp/packages

错误:

Looking in links: file:///tmp/packages
Requirement already satisfied: asgiref==3.2.3 in d:\virtual_envs\scolarte\lib\site-packages (from -r requirements-dev.txt (line 1)) (3.2.3)
Collecting boto3==1.12.0 (from -r requirements-dev.txt (line 2))
  Url 'file:///tmp/packages' is ignored: it is neither a file nor a directory.
  Could not find a version that satisfies the requirement boto3==1.12.0 (from -r requirements-dev.txt (line 2)) (from versions: )
No matching distribution found for boto3==1.12.0 (from -r requirements-dev.txt (line 2))

但是调用时安装了软件包:

pip install boto3==1.12.0

为什么?

a)requirements.txt:

-r requirements-dev.txt
gunicorn
psycopg2

b)Requirements-dev.txt

asgiref==3.2.3
boto3==1.12.0
botocore==1.14.16
defusedxml==0.6.0
diff-match-patch==20181111
dj-database-url==0.5.0
dj-static==0.0.6
Django==3.0.3
django-crispy-forms==1.8.1
django-import-export==2.0.1
django-sendgrid-v5==0.8.1
django-storages==1.9.1
djangorestframework==3.11.0
docutils==0.15.2
et-xmlfile==1.0.1
future==0.18.2
jdcal==1.4.1
jmespath==0.9.4
MarkupPy==1.14
numpy==1.18.1
odfpy==1.4.1
openpyxl==3.0.3
pandas==0.25.3
Pillow==7.0.0
python-dateutil==2.8.1
python-decouple==3.3
python-http-client==3.2.4
pytz==2019.3
PyYAML==5.3
s3transfer==0.3.3
sendgrid==6.1.1
six==1.14.0
sqlparse==0.3.0
static3==0.7.0
tablib==0.14.0
urllib3==1.25.8
xlrd==1.2.0
xlwt==1.3.0

1 个答案:

答案 0 :(得分:3)

使用时

pip install boto3==1.12.0

您正在从PyPI (The Python Package Index)安装。而使用{p>中的--no-index选项

pip install -r requirements.txt --no-index --find-links file:///tmp/packages

您明确告诉pip不要在PyPI中查找它。

形成PyPI Documentation

-无索引

忽略软件包索引(仅查看--find-links URL)。

-f,-查找链接 <url>

如果是html文件的url或路径,则解析到存档的链接。如果是本地路径或file://网址, 目录,然后在目录列表中查找档案。

也在how pip finds packages(重点是我)上

pip在许多地方查找软件包:在PyPI上(如果未禁用) 通过--no-index)在本地文件系统中以及其他任何方式中 通过--find-links或--index-url指定的存储库。没有 在搜索到的位置排序。而是全部 选中,并且“最佳”匹配要求(就 版本号-有关详细信息,请参见PEP 440。