linux新建conda环境
时间: 2025-03-22 09:02:04 浏览: 49
### 创建一个新的 Conda 环境
在 Linux 下创建一个新的 Conda 环境可以通过 `conda` 命令实现。以下是关于如何操作的具体说明:
#### 使用命令创建新环境
通过运行以下命令可以创建一个名为 `myenv` 的新环境,并指定 Python 版本为 3.9:
```bash
conda create --name myenv python=3.9
```
这条命令会初始化一个新的虚拟环境并安装所选版本的 Python[^1]。
#### 激活新建的环境
一旦环境被成功创建,就可以使用下面的命令激活它:
```bash
conda activate myenv
```
此命令将切换到刚创建的环境中工作[^2]。
#### 安装额外包至特定环境
如果需要向这个新环境中添加其他软件包,则可以在激活该环境之后执行如下指令来完成安装过程:
```bash
conda install numpy pandas matplotlib
```
或者也可以利用 pip 工具来进行相同的操作:
```bash
pip install requests flask django
```
需要注意的是,在同一时间只有一个活动中的 conda 环境;因此当您希望针对不同项目分别管理其依赖关系时,建议分别为它们各自建立独立的 conda environments 来隔离这些项目的库文件及其配置设置等内容[^3]。
#### 删除不再使用的环境
如果您决定停止使用某个已有的 conda environment 并想彻底移除它的话,请先确保当前未处于目标要删除的那个 env 中(即已经deactivate),然后再输入相应的 remove 命令即可将其销毁掉:
```bash
conda deactivate
conda remove --name old_env_name --all
```
---
### Pip Install vs Conda Install 区别概述
尽管两者都能用于Python packages management, but they have some key differences that make them suitable under different circumstances:
- **Package Source**: While both can access PyPI (the official third-party software repository), only Conda has its own channel system which includes not just pure-python libraries but also compiled binaries like C/C++ extensions or Fortran codes etc., making it more versatile especially when dealing with scientific computing related tasks where performance matters most.
- **Dependency Resolution & System Integration**: One major advantage of using Conda over PIP is better handling dependencies across multiple languages/platforms as well as integrating smoothly into non-Python ecosystems such as R-langauge projects.
- **Performance Considerations**: Packages installed via Conda often come precompiled thus potentially leading faster setup times compared against those obtained solely through source distributions provided by PIP from PyPi servers unless you're building everything yourself locally anyway!
综上所述,对于涉及复杂跨平台应用开发场景下的需求来说,选用Conda可能更为合适一些因为它能够提供更加全面的支持服务。
---
阅读全文
相关推荐


















