简体   繁体   中英

How to install a package for specific python version

I have two versions of python (3 and 2) and Python 2 is the default one, I want to install a specific package only for Python 3,

I am using windows 7

whenever i use pip install, it is installing python 2 package

How to specify which python version for pio install

python -m pip install package

python3 -m pip install package

This is how you would do it using pip for v2 and v4 respectively.

On windows you can use the following commands in command line:

# For Python 2
pip2 install package_name
# For Python 3
pip3 install package_name

Alternate way:

# For Python 2
py -2 -m pip install package_name
# For Python 3
py -3 -m pip install package_name

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.

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