如何在 Anaconda 中为不同的 Python 版本安装包?

2022-01-10 00:00:00 python conda anaconda

问题描述

我有 Python 2.7 作为 root.我需要在 Python 3.6 中安装包statistics",它不在 anaconda navigator 的环境中.如何使用 condapip 为辅助 Python 环境安装statistics"?

I have Python 2.7 as root. I need to install the package "statistics" in Python 3.6, and it is not in the environments of anaconda navigator. How can install "statistics" with conda or pip for a secondary Python environment?


解决方案

通过运行创建一个新的 Python 3 环境:

Create a new Python 3 environment by running:

conda create --name python3 python=3

如果您希望默认安装所有标准 anaconda 软件包,请执行以下操作:

If you want all the standard anaconda packages installed by default, do:

conda create --name python3 python=3 anaconda

当你需要使用 python3 时运行:

Whenever you need to use python3 run:

activate python3

然后正常使用命令行.所以,如果你想在你的 python3 环境中安装一些东西,请确保你首先 activate python3.

Then use the command line as normal. So, if you want to install something into your python3 environment, make sure you activate python3 first.

请注意,python 3 拥有自己的统计模块,您可能会发现它很有用,如果您愿意,此模块 已移植到 python 2.

Note that python 3 has it's own statistics module that you may find useful, and this module has been ported to python 2 if you would prefer.

相关文章