简体   繁体   English

pip 使用 requirements.txt 安装时拒绝二进制文件

[英]pip rejects binaries when installing using requirements.txt

Why does Python pip reject binaries when installing package from requirements.txt ?为什么 Python piprequirements.txt安装 package 时拒绝二进制文件?
I am not using --no-binary , and I could not find any mention that this could be the default.我没有使用--no-binary ,而且我找不到任何提及这可能是默认设置的信息。 It definitely is not when installing without requirements.txt .在没有requirements.txt的情况下安装肯定不是。

When I install django-silk package in this way, it succeeds:当我这样安装django-silk package时,成功了:

pip install -v django-silk==4.1.0

But when django-silk==4.1.0 is in my requirements.txt , and I run this exact command line:但是当django-silk==4.1.0在我的requirements.txt中时,我运行这个确切的命令行:

pip install -v -r requirements-prod.txt

I get the following log:我得到以下日志:

(...)
  Skipping link: No binaries permitted for django-silk: (...)
  Found link (...) version: 3.0.4
  Skipping link: No binaries permitted for django-silk: (...)
  Found link  (...) version: 4.0.0
  Skipping link: No binaries permitted for django-silk: https://files.pythonhosted.org/(...)/django_silk-4.0.0-py2.py3-none-any.whl (...)
  Skipping link: No binaries permitted for django-silk: https://files.pythonhosted.org/(...)/django_silk-4.0.1-py2.py3-none-any.whl (...)
  Skipping link: No binaries permitted for django-silk: https://files.pythonhosted.org/(...)/django_silk-4.1.0-py2.py3-none-any.whl (...)
Given no hashes to check 0 links for project 'django-silk': discarding no candidates
(...)
pip._internal.exceptions.DistributionNotFound: No matching distribution found for django-silk==4.1.0

Why does pip decide that No binaries permitted for django-silk ?为什么pip决定No binaries permitted for django-silk

Update: It seems that the issue is not with requirements.txt file itself, but in the fact that requirements.txt also contains another package:更新:似乎问题不在于requirements.txt文件本身,但事实上requirements.txt还包含另一个 package:

PyYAML --global-option="--with-libyaml" ; sys_platform != 'win32'
django-silk==4.1.0

So apparently the fact that PyYAML must be installed from source makes pip ignore binary packages for django-silk as well.显然, PyYAML必须从源代码安装这一事实使得pip忽略了django-silk的二进制包。 Why does that happen?为什么会这样?

Note: I am using Python 3.7.5 and pip 21.0.1 .注意:我正在使用Python 3.7.5pip 21.0.1

So it turns out this is caused by a bug in pip :所以事实证明这是由pip中的错误引起的:
"--global-option for a specific requirement in requirements file disables use of wheels globally" “--要求文件中特定要求的全局选项禁用全局使用轮子”
https://github.com/pypa/pip/issues/4118 https://github.com/pypa/pip/issues/4118

Why does Python pip reject binaries when installing package from requirements.txt ?为什么 Python pip在从requirements.txt安装 package 时拒绝二进制文件?
I am not using --no-binary , and I could not find any mention that this could be the default.我没有使用--no-binary ,也找不到任何提及这可能是默认设置的内容。 It definitely is not when installing without requirements.txt .在没有requirements.txt的情况下安装绝对不是。

When I install django-silk package in this way, it succeeds:当我以这种方式安装django-silk package 时,它成功了:

pip install -v django-silk==4.1.0

But when django-silk==4.1.0 is in my requirements.txt , and I run this exact command line:但是当django-silk==4.1.0在我的requirements.txt中时,我运行这个确切的命令行:

pip install -v -r requirements-prod.txt

I get the following log:我得到以下日志:

(...)
  Skipping link: No binaries permitted for django-silk: (...)
  Found link (...) version: 3.0.4
  Skipping link: No binaries permitted for django-silk: (...)
  Found link  (...) version: 4.0.0
  Skipping link: No binaries permitted for django-silk: https://files.pythonhosted.org/(...)/django_silk-4.0.0-py2.py3-none-any.whl (...)
  Skipping link: No binaries permitted for django-silk: https://files.pythonhosted.org/(...)/django_silk-4.0.1-py2.py3-none-any.whl (...)
  Skipping link: No binaries permitted for django-silk: https://files.pythonhosted.org/(...)/django_silk-4.1.0-py2.py3-none-any.whl (...)
Given no hashes to check 0 links for project 'django-silk': discarding no candidates
(...)
pip._internal.exceptions.DistributionNotFound: No matching distribution found for django-silk==4.1.0

Why does pip decide that No binaries permitted for django-silk ?为什么pip决定No binaries permitted for django-silk

Update: It seems that the issue is not with requirements.txt file itself, but in the fact that requirements.txt also contains another package:更新:似乎问题不在于requirements.txt文件本身,但事实上requirements.txt还包含另一个 package:

PyYAML --global-option="--with-libyaml" ; sys_platform != 'win32'
django-silk==4.1.0

So apparently the fact that PyYAML must be installed from source makes pip ignore binary packages for django-silk as well.显然,必须从源代码安装PyYAML的事实使得pip忽略了django-silk的二进制包。 Why does that happen?为什么会这样?

Note: I am using Python 3.7.5 and pip 21.0.1 .注意:我正在使用Python 3.7.5pip 21.0.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM