I have Python 3.7 and Python 3.6. How to I chose to which version of Python I want my PIP packages?
On Linux the @jwodder answer is fine, but on Windows use the Python Launcher, which is normally installed by default. You specify the version of Python to launch as -XY
, eg:
py -3.6 -m pip install ...
You use the version of pip
that corresponds to the desired Python version. The most universally effective way is to run pythonX.Y -m pip install ...
, where XY
is replaced with the Python version number, though running just pipX.Y install ...
may also work under some circumstances.
使用python -m pip
其中 python 是您要安装到的 python 版本
I would suggest to use the newer and (now) recommended way of installing Python application dependencies: pipenv . You can consider pipenv
to be the better pip
( pip
+ virtualenv
handling + proper depedency management). Using pipenv you create a Pipfile
and you can specify the exact python_version
you want to use in that file. Since I started using pipenv
in my projects most headaches I had previously with Python dependency and version management are gone.
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.