这里推荐使用 Miniconda
官方文档 - 下载 :https://docs.anaconda.com/miniconda/install/
安装包地址:https://www.anaconda.com/download/success
支持 Windows、macOS、Linux
macOS 在下载 pkg 安装包后,双击安装来安装;
安装成功后,将在终端 prompt 看到 (base)
,代表你进入了 base conda 环境。
你可以在终端输入下面命令来测试:
conda list
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
你可以在这里找到低版本的 脚本、安装器
https://repo.anaconda.com/miniconda/
安装成功后,运行下面命令来激活环境
source ~/miniconda3/bin/activate
让 conda 在所有 shells 上有效,运行以下命令:
conda init --all
查看当下有哪些环境
conda info -e
创建环境
基于 python 3.11
此处我命名环境名为 e311,你可以改为自己的名字
conda create -n e311 python=3.11
复制环境
如果环境 e311 已经有一些很方便的包,但需要创建新环境,可以复制 e311
conda create -n e3112 --clone e311
切换环境
% conda info -e
# conda environments:
#
base * /Users/shushu/miniconda3
e311 /Users/shushu/miniconda3/envs/e311
(base) % conda activate e311
(e311) % conda activate base
退出环境
conda deactivate
移除环境
conda remove -n e311 --all
修改环境名
conda create --name e11 --clone e311
conda remove --name e311 --all
查看已经安装的package
conda list
安装包
conda install numpy
安装指定版本
conda install numpy==3.45.3
指定环境参数安装(-n
)
conda install -n e11 numpy
终端前显示了 环境名后,使用 pip install
也可以安装到当下环境
在源仓库查找包
conda search sqlite
将返回历史版本信息
% conda search sqlite
Loading channels: done
# Name Version Build Channel
sqlite 3.20.1 h7e4c145_2 pkgs/main
sqlite 3.20.1 h900c3b0_1 pkgs/main
sqlite 3.21.0 h3efe00b_0 pkgs/main
sqlite 3.21.0 h3efe00b_2 pkgs/main
...
更新包
conda update numpy
卸载包
conda remove numpy
其它命令:
% conda --help
usage: conda [-h] [-v] [--no-plugins] [-V] COMMAND ...
conda is a tool for managing and deploying applications, environments and packages.
options:
-h, --help Show this help message and exit.
-v, --verbose Can be used multiple times. Once for detailed output, twice for INFO logging, thrice for DEBUG logging,
four times for TRACE logging.
--no-plugins Disable all plugins that are not built into conda.
-V, --version Show the conda version number and exit.
commands:
The following built-in and plugins subcommands are available.
COMMAND
activate Activate a conda environment.
clean Remove unused packages and caches.
compare Compare packages between conda environments.
config Modify configuration values in .condarc.
content-trust Signing and verification tools for Conda
create Create a new conda environment from a list of specified packages.
deactivate Deactivate the current active conda environment.
doctor Display a health report for your environment.
env See `conda env --help`.
info Display information about current conda install.
init Initialize conda for shell interaction.
install Install a list of packages into a specified conda environment.
list List installed packages in a conda environment.
notices Retrieve latest channel notifications.
package Create low-level conda packages. (EXPERIMENTAL)
remove (uninstall)
Remove a list of packages from a specified conda environment.
rename Rename an existing environment.
repoquery Advanced search for repodata.
run Run an executable in a conda environment.
search Search for packages and display associated information using the MatchSpec format.
update (upgrade) Update conda packages to the latest compatible version.
伊织 2025-01-17(五)
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。