[英]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.我已经在 Python 3.6 上安装了漂亮的桌子,但我想在 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.因此,当我执行pip install prettytable
时,它表明 package 已经为 3.6 安装了,但就像我说的那样,我也想在 ZA7F5F35426B927411FC9231B5638271 上安装它。
How can I do that?我怎样才能做到这一点? I need both versions of Python for different projects.对于不同的项目,我需要两个版本的 Python。 I use VSCode.我使用 VSCode。
You can check which python versions you have and where are they stored by running:您可以通过运行检查您拥有哪些 python 版本以及它们存储在哪里:
whereis python
Then knowing where is your python3.8 installed, just run this with the absolute path.然后知道你的python3.8安装在哪里,用绝对路径运行它。
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.这取决于您的系统以及启动不同 Python 版本的方式。
On Windows, you would use the py
launcher:在 Windows 上,您将使用py
启动器:
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:在 Linux 或任何其他类 Unix 上,您通常直接运行各种安装的 python 可执行文件,其版本作为后缀,所以它应该是:
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.如果您想在 PC 上处理不同的 python 版本,我强烈建议您在这种情况下使用anaconda
(或最小版本miniconda
)。
Miniconda is easy to use and helps you manage your python environments. Miniconda 易于使用,可帮助您管理 python 环境。 Putting myself in your shoes, I would install miniconda
from here , and do the following.设身处地为您着想,我会从这里安装miniconda
,然后执行以下操作。
Open anaconda prompt
and type:打开anaconda prompt
并键入:
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
.您可以按照此文档了解如何在VS CODE
中激活 python 环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.