Python conda
王哲峰 / 2022-07-13
目录
Conda 介绍
系统要求:
- 32- or 64-bit computer.
- For Miniconda—400 MB disk space.
- For Anaconda—Minimum 3 GB disk space to download and install.
- Windows, macOS, or Linux.
下载安装方式:
- Miniconda
- conda
- conda dependencies
- Anaconda
- conda
- 7500+ open-source packages
- Silent mode
- Windows
- macOS
- Linux
- 多 Python 环境中安装
- 为了安装 Conda 不需要卸载其他 Python 环境,其他 Python 环境如下:
- 系统中自带安装的 Python
- 从 macOS Homebrew 包管理工具中安装的 Python
- 从 pip 安装的 Python 包
- 为了安装 Conda 不需要卸载其他 Python 环境,其他 Python 环境如下:
1.如何检查当前环境中是否安装了 Conda?
- Windows(Anaconda Prompt)
echo %PATH%
- macOS 和 Linux
echo $PAHT
2.如何检查当前环境中默认的 Python 环境?
- Windows(Anaconda Prompt)
where python
- macOS 和 Linuxwhich python
Conda 安装
Conda 下载
Conda 安装
- Windows
- macOS
- Linux
Conda 使用
Package, dependency and environment management for any language—Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++, FORTRAN, and more.
- conda 管理
- packages 管理
- virtual packages 管理
- environment 管理
- channels 管理
- Python 管理
conda 管理
1.验证 conda 是否已经安装
conda --version
2.确定 conda 版本
conda info
conda -V
3.将 conda 更新到当前版本
conda update conda
4.禁止显示有关更新 conda 的警告消息
conda update -n base conda
conda config --set notify_outdated_conda false
# ~/.conda
notify_updated_conda: false
packages 管理
virtual packages 管理
environment 管理
channels 管理
Python 管理
Conda treats Python the same as any other package, so it is easy to manage and update multiple installations.
- Anaconda supports Python 2.7, 3.6, and 3.7.
The default is Python 2.7 or 3.7,
depending on which installer you used:
- For the installers “Anaconda” and “Miniconda,” the default is 2.7.
- For the installers “Anaconda3” or “Miniconda3,” the default is 3.7.
- 查看可供 conda 下载的 Python 版本列表
conda search python
conda search --full-name python
- 安装其他版本的 Python
安装其他版本的 Python 并不覆盖目前已经存在的版本.
(1)创建新环境
conda create -n py36 python=3.6 anaconda
conda create -n py36 python=3.7 miniconda
conda create -n py27 python=2.7 anaconda
(2)激活新环境
- 参考 切换其他版本的 Python
(3)验证新环境是否为当前环境 (4)验证当前环境
python --version
-
切换其他版本的 Python
-
(1)如果当前环境是 conda 环境:
- 1.激活环境
conda activate myenv
- 2.停用环境
conda deactivate
-
(2)如果当前环境不是 conda 环境:
- Windows
D:\Miniconda\Script\acitvate base
- macOS 或 Linux
~/opt/miniconda3/bin/activate base
- 嵌套环境
(doc)$ codna activate --stack myenv $ conda config -set auto_stack 1
- Conda init
conda init auto_activate_base: bool
-
-
更新或升级 Python
conda update python
conda install python=3.6