Tag Archives: pip install

pip install poetry Export requirements.txt Error: ERROR: In –require-hashes mode, all requirements must have their versions pinned with ==. These do not: cffi>=1.1 from https://…..

background

Python 3.9

pip 21.2.3

poetry   1.1.8

Execute the command to export requirements.txt

 poetry export  -f requirements.txt --output requirements.txt

seerequirements.txt

Each library has a hash encryption field

Execute the PIP install command

pip3 install --no-cache-dir --upgrade  -r requirements.txt

It’s wrong

#8 28.40 Collecting websockets==10.0
#8 28.51   Downloading websockets-10.0-cp39-cp39-manylinux2010_x86_64.whl (107 kB)
#8 29.38 Collecting cffi>=1.1
#8 29.38 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
#8 29.38     cffi>=1.1 from https://files.pythonhosted.org/packages/be/2a/6d266eea47dbb2d872bbd1b8954a2d167668481ff34ebb70ffdd1113eeab/cffi-1.14.6-cp39-cp39-manylinux1_x86_64.whl#sha256=f3ebe6e73c319340830a9b2825d32eb6d8475c1dac020b4f0aa774ee3b898d1c (from bcrypt==3.2.0->-r /code/requirements.txt (line 19))
------
executor failed running [/bin/sh -c pip install --no-cache-dir --upgrade -r /code/requirements.txt]: exit code: 1

Troubleshooting ideas

Uninstall cffi library and reinstall it. No

Regenerate the requirements.txt file and then install it. No

No, Google searched and found the issue of similar problems. It seems that it is a known problem, and the official poetry hasn’t fixed it yet. It only provides a way to avoid it

https://github.com/actions/virtual-environments/issues/2245

Solution

This flag is passed in the poetry export command  — without-hashes

poetry export --without-hashes -f requirements.txt --output requirements.txt

I use this method. It can be used in practice. It is suitable for small partners who use poetry

The following scenes have not been tried

Scene 1

Stop using PIP — constraints flag to pass packages with fixed hashes

Scene 2

If you use PIP directly, fix it to versions before 20.3

python -m pip install --upgrade pip==20.2.4

Scene 3

If you are using another   Virtualenv depends on pip. Please ensure that its version is fixed

python -m pip install --upgrade virtualenv==20.0.26

Or use the environment variable virtualenv_ PIP=20.2.4

PIP install troubleshooting under Windows [How to Solve]

Error:

Traceback (most recent call last): File"C:\Python27\Python27\Scripts\pip-script.py", line 9, in<module> load_entry_point('pip==1.4.1','console_scripts', 'pip')() File"C:\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\__init__
 .py", line 148, in main

return command.main(args[1:], options) File"C:\Python27\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\basecomm
 and.py", line 169, in main
 text = '\n'.join(complete_log) UnicodeDecodeError: 'ascii' codec can't decode byte 0xb1 inposition 34: ordinal
 not in range(128)

Reason:
the CMD environment of windows defaults to GBK encoding, and pip defaults to UTF-8 encoding
however, in Linux and MAC, the terminal environment defaults to UTF-8 encoding, so no error will be reported

Solution:

Create a file sitecustomize.py in Python directory Python 27\lib\site-packages

import sys sys.setdefaultencoding('gbk')

Python will run this file automatically

 

Error reported by PIP install third-party library [How to Solve]

reward :Could not find a version that satisfies the requirement xlrd (from versions: )

No matching distribution found for xlrd

This is because of China’s 32476 problem, it needs to be used faster, like peanuts.

Method 1:

The order reads.

pip install xlrd http://pypi.douban.com/simple/ –trusted-host pypi.douban.com

or

pip3 install xlrd http://pypi.douban.com/simple/ –trusted-host pypi.douban.com

Method 2:

Delay 36831; Time

command: pip –default-timeout=100 install xlrd obey

Method 3:

under the pip installation path, create python file

import os  

ini="""[global] 
index-url = https://pypi.doubanio.com/simple/ 
[install] 
trusted-host=pypi.doubanio.com 
"""  
pippath=os.environ["USERPROFILE"]+"\\pip\\"  

if not os.path.exists(pippath):  
    os.mkdir(pippath)  

with open(pippath+"pip.ini","w+") as f:  
    f.write(ini)  

Run the python file on CMD, and then use the PIP install command to install it, which is very fast