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

2024-04-28 21:28:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我有两个与需求相关的文件。我在打电话时遇到以下错误:

$ 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)需求-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

Tags: installpipdjangofromdevtxtpackages错误
1条回答
网友
1楼 · 发布于 2024-04-28 21:28:53

当你使用

pip install boto3==1.12.0

您正在从PyPI (The Python Package Index)安装。而通过在

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

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

形成PyPI Documentation

no-index

Ignore package index (only looking at find-links URLs instead).

-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.

还有关于how pip finds packages(重点是我的)

pip looks for packages in a number of places: on PyPI (if not disabled via no-index), in the local filesystem, and in any additional repositories specified via find-links or index-url. There is no ordering in the locations that are searched. Rather they are all checked, and the “best” match for the requirements (in terms of version number - see PEP 440 for details) is selected.

相关问题 更多 >