It seems to be common practice to set up a Python virtual environment using some variant of the following:
python -m venv venv && source ./venv/bin/activate
python -m pip install -U pip -r requirements.txt
What I hope the above command does is:
pip
firstrequirements.txt
However, what actually seems to happen is:
pip
pip
is what actually runs the installs pip
is not used until after this commandQuestion(s)
python -m venv venv && source ./venv/bin/activate
python -m pip install -U pip
python -m pip install -r requirements.txt
wheel
and setuptools
as wellThe answers to your questions are:
pip
doesn't currently treat itself as a special dependency, so it doesn't know to install then execute itself, which is what it would need to do to overcome the problems you observed.pip
in a separate step is indeed the recommended way to proceed. You may from time to time see pip
issue a message advising that a newer version is available. This happens a lot if you create them from a python with an outdated pip
.
I had a situation similar to yours, I needed to first upgrade pip
and then install a bunch of libraries in a lab that had 20 PCs. What I did was writing all the librarie's name in a requirements.txt
file, then create a .bat
file with two commands:
`python -m pip install --upgrade pip`
`pip install -r requirements.txt`
The first command for upgrading pip
and the second one for installing all the libraries listed in the requirements.txt
file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.