1. 基本命令
1. 确认版本:
conda -v
2. 查看命令参数: conda, 可以看到子命令有clean、help、list、install、search等子命令
PS F:\Note> conda
usage: conda-script.py [-h] [--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.
--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
build Build conda packages from a conda recipe.
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
convert Convert pure Python packages to other platforms (a.k.a., subdirs).
create Create a new conda environment from a list of specified packages.
debug Debug the build or test phases of conda recipes.
develop Install a Python package in 'development mode'. Similar to `pip install --editable`.
doctor Display a health report for your environment.
env See `conda env --help`.
index Update package index metadata files. Pending deprecation, use https://github.com/conda/conda-
index instead.
info Display information about current conda install.
init Initialize conda for shell interaction.
inspect Tools for inspecting conda packages.
install Install a list of packages into a specified conda environment.
list List installed packages in a conda environment.
metapackage Specialty tool for generating conda metapackage.
notices Retrieve latest channel notifications.
pack See `conda pack --help`.
package Create low-level conda packages. (EXPERIMENTAL)
remove (uninstall)
Remove a list of packages from a specified conda environment.
rename Rename an existing environment.
render Expand a conda recipe into a platform-specific recipe.
repo See `conda repo --help`.
run Run an executable in a conda environment.
search Search for packages and display associated information using the MatchSpec format.
server See `conda server --help`.
skeleton Generate boilerplate conda recipes.
token See `conda token --help`.
update (upgrade) Update conda packages to the latest compatible version.
verify See `conda verify --help`.
3. 查看子命令帮助信息: conda [子命令] -h
conda create -h
usage: conda-script.py create [-h] [--clone ENV] (-n ENVIRONMENT | -p PATH) [-c CHANNEL] [--use-local] [--override-channels] [--repodata-fn REPODATA_FNS] [--experimental {jlap,lock}] [--strict-channel-priority] [--no-channel-priority] [--no-deps | --only-deps] [--no-pin]
[--copy] [--no-shortcuts] [-C] [-k] [--offline] [--json] [-v] [-q] [-d] [-y] [--download-only] [--show-channel-urls] [--file FILE] [--no-default-packages] [--solver {classic,libmamba} | --experimental-solver {classic,libmamba}] [--dev]
[package_spec ...]
Create a new conda environment from a list of specified packages. To use the newly-created environment, use 'conda activate envname'. This command requires either the -n NAME or -p PREFIX option.
positional arguments:
package_spec List of packages to install or update in the conda environment.
options:
-h, --help Show this help message and exit.
--clone ENV Create a new environment as a copy of an existing local environment.
--file FILE Read package versions from the given file. Repeated file specifications can be passed (e.g. --file=file1 --file=file2).
--dev Use `sys.executable -m conda` in wrapper scripts instead of CONDA_EXE. This is mainly for use during tests where we test new conda sources against old Python versions.
Target Environment Specification:
-n ENVIRONMENT, --name ENVIRONMENT
Name of environment.
-p PATH, --prefix PATH
Full path to environment location (i.e. prefix).
Channel Customization:
-c CHANNEL, --channel CHANNEL
Additional channel to search for packages. These are URLs searched in the order they are given (including local directories using the 'file://' syntax or simply a path like '/home/conda/mychan' or '../mychan'). Then, the defaults or channels from
.condarc are searched (unless --override-channels is given). You can use 'defaults' to get the default packages for conda. You can also use any name and the .condarc channel_alias value will be prepended. The default channel_alias is
https://conda.anaconda.org/.
--use-local Use locally built packages. Identical to '-c local'.
--override-channels Do not search default or .condarc channels. Requires --channel.
--repodata-fn REPODATA_FNS
Specify file name of repodata on the remote server where your channels are configured or within local backups. Conda will try whatever you specify, but will ultimately fall back to repodata.json if your specs are not satisfiable with what you specify
here. This is used to employ repodata that is smaller and reduced in time scope. You may pass this flag more than once. Leftmost entries are tried first, and the fallback to repodata.json is added for you automatically. For more information, see conda
config --describe repodata_fns.
--experimental {jlap,lock}
jlap: Download incremental package index data from repodata.jlap; implies 'lock'. lock: use locking when reading, updating index (repodata.json) cache.
Solver Mode Modifiers:
--strict-channel-priority
Packages in lower priority channels are not considered if a package with the same name appears in a higher priority channel.
--no-channel-priority
Package version takes precedence over channel priority. Overrides the value given by `conda config --show channel_priority`.
--no-deps Do not install, update, remove, or change dependencies. This WILL lead to broken environments and inconsistent behavior. Use at your own risk.
--only-deps Only install dependencies.
--no-pin Ignore pinned file.
--no-default-packages
Ignore create_default_packages in the .condarc file.
--solver {classic,libmamba}
Choose which solver backend to use.
--experimental-solver {classic,libmamba}
`--experimental-solver` is pending deprecation and will be removed in 24.3. Use `--solver` instead.
Package Linking and Install-time Options:
--copy Install all packages using copies instead of hard- or soft-linking.
--no-shortcuts Don't install start menu shortcuts
Networking Options:
-C, --use-index-cache
Use cache of channel index files, even if it has expired. This is useful if you don't want conda to check whether a new version of the repodata file exists, which will save bandwidth.
-k, --insecure Allow conda to perform "insecure" SSL connections and transfers. Equivalent to setting 'ssl_verify' to 'false'.
--offline Offline mode. Don't connect to the Internet.
Output, Prompt, and Flow Control Options:
--json Report all output as json. Suitable for using conda programmatically.
-v, --verbose Can be used multiple times. Once for INFO, twice for DEBUG, three times for TRACE.
-q, --quiet Do not display progress bar.
-d, --dry-run Only display what would have been done.
-y, --yes Sets any confirmation values to 'yes' automatically. Users will not be asked to confirm any adding, deleting, backups, etc.
--download-only Solve an environment and ensure package caches are populated, but exit prior to unlinking and linking packages into the prefix.
--show-channel-urls Show channel urls. Overrides the value given by `conda config --show show_channel_urls`.
Examples:
Create an environment containing the package 'sqlite'::
conda create -n myenv sqlite
Create an environment (env2) as a clone of an existing environment (env1)::
conda create -n env2 --clone path/to/file/env1
2. 环境:创建/删除
conda最有特色的点,可以便利创建不同的开发环境,对开发环境进行管理
1. 查看既存环境:conda env list
conda env list
# conda environments:
#
base E:\Install_path_program\anaconda3
2. 环境的查找和创建
- 查找环境
conda search nodejs
-
创建环境
conda create -n [环境名称] [安装库包列表] (-n 等同于 -name,表示要创建的环境名称,-y 表示安装中默认选择yes)- python
conda create -n python3816 python=3.8.16- nodejs
conda create -name frida_nodejs nodejs=16.15.0 conda create -yn myapp nodejs
创建过程
conda create -n python3816 python=3.8.16
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 23.7.4
latest version: 23.9.0
Please update conda by running
$ conda update -n base -c defaults conda
Or to minimize the number of packages updated during conda update use
conda install conda=23.9.0
## Package Plan ##
environment location: E:\Install_path_program\anaconda3\envs\python3816
added / updated specs:
- python=3.8.16
The following packages will be downloaded:
package | build
---------------------------|-----------------
openssl-3.0.11 | h2bbff1b_2 7.4 MB
pip-23.2.1 | py38haa95532_0 2.8 MB
python-3.8.16 | h1aa4202_4 18.9 MB
setuptools-68.0.0 | py38haa95532_0 925 KB
wheel-0.41.2 | py38haa95532_0 126 KB
------------------------------------------------------------
Total: 30.1 MB
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/win-64::ca-certificates-2023.08.22-haa95532_0
libffi pkgs/main/win-64::libffi-3.4.4-hd77b12b_0
openssl pkgs/main/win-64::openssl-3.0.11-h2bbff1b_2
pip pkgs/main/win-64::pip-23.2.1-py38haa95532_0
python pkgs/main/win-64::python-3.8.16-h1aa4202_4
setuptools pkgs/main/win-64::setuptools-68.0.0-py38haa95532_0
sqlite pkgs/main/win-64::sqlite-3.41.2-h2bbff1b_0
vc pkgs/main/win-64::vc-14.2-h21ff451_1
vs2015_runtime pkgs/main/win-64::vs2015_runtime-14.27.29016-h5e58377_2
wheel pkgs/main/win-64::wheel-0.41.2-py38haa95532_0
Proceed ([y]/n)? Y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate python3816
#
# To deactivate an active environment, use
#
# $ conda deactivate
查看环境列表:conda env list
conda env list
# conda environments:
#
base E:\Install_path_program\anaconda3
python3816 E:\Install_path_program\anaconda3\envs\python3816
3. 初始化 conda
需要初始化 否则在激活环境的时候会报错
conda init
4. 包的安装
-
- 创建虚拟环境时安装包:requests、numpy 环境名称:coder-study
conda create -n coder-study requests numpy
-
- 在Step1创建的环境上还想继续安装包:scripy
conda install -n python3816 scipy
-
- 直接使用 pip 安装
pip install requests
5. 查看装的库
注:用conda安装的包,conda都能进行管理,因为我们使用pip安装的,所以查看不到
conda list
4. 启动新创建环境
conda activate python3816
3. 环境的删除
conda remove -n [环境名称] --all
conda remove -n python3816 --all
4. 环境包导入和导出
1. 导出base环境yml文件
conda env export --file coder-base.yml --name python3816
2. 导入环境yml 文件
conda env create -f coder-base.yml
5. 镜像源的配置和查看
1. 配置
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
2. 查看
conda config --get channels
conda config --add channels 'defaults' # lowest priority
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/'
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/' # highest priority
浙公网安备 33010602011771号