简体   繁体   中英

Install the same package on two different versions of Python

I already have pretty table installed on Python 3.6 but I want to install it on python 3.8. So when I do pip install prettytable , it shows that the package has already been installed for 3.6 but like I said that I also want it on Python 3.8.

How can I do that? I need both versions of Python for different projects. I use VSCode.

You can check which python versions you have and where are they stored by running:

whereis python

Then knowing where is your python3.8 installed, just run this with the absolute path.

For example:

/usr/bin/python3.8 -m pip install prettytable
or
/usr/local/bin/python3.8 -m pip install prettytable

It depends on your system and on the way you can start the different Python versions.

On Windows, you would use the py launcher:

py -3.8 -m pip install package_name

On Linux or any other Unix-like, you normally run directly the various installed python executable with their version as a suffix, so it should be:

python3.8 -m pip install package_name

If you want an alternative to dealing with different python versions on your PC, I extremely recommend using anaconda (or the minimal version miniconda ) in such cases.

Miniconda is easy to use and helps you manage your python environments. Putting myself in your shoes, I would install miniconda from here , and do the following.

Open anaconda prompt and type:

conda create -n some_env_name python=3.8
conda activate some_env_name
pip install prettytable

You can follow this document on how to activate a python environment in VS CODE .

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