conda create --name venvname python=3.12.10 # 可以制定python版本
conda activate venvname # 激活虚拟环境
pip install xxx
conda deactivate venvname
虚拟环境列表
conda env list
删除虚拟环境
conda remove -n your_env_name --all # 彻底删除虚拟环境
修改虚拟环境名称
conda rename -n <旧名称> <新名称>
如果老版本没有改虚拟环境名称的命令,可以删除后重建。
另一种办法是直接改虚拟环境目录名称即可。
清理 Conda 缓存
conda clean --all --yes
conda create --prefix=D:\Programs\anaconda3\envs\venvname python=3.12.10 # 解决默认路径问题
默认路径设置:搜索:.condarc envs_dirs
帮助文档:
conda create --help
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}]
[--no-lock] [--repodata-use-zst | --no-repodata-use-zst] [--strict-channel-priority]
[--no-channel-priority] [--no-deps | --only-deps] [--no-pin] [--copy] [--no-shortcuts]
[--shortcuts-only SHORTCUTS_ONLY] [-C] [-k] [--offline] [--json] [--console CONSOLE]
[-v] [-q] [-d] [-y] [--download-only] [--show-channel-urls] [--file FILE]
[--no-default-packages] [--subdir SUBDIR] [--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, --name ENVIRONMENT
Name of environment.
-p, --prefix PATH Full path to environment location (i.e. prefix).
Channel Customization:
-c, --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. Now enabled.
--no-lock Disable locking when reading, updating index (repodata.json) cache.
--repodata-use-zst, --no-repodata-use-zst
Check for/do not check for repodata.json.zst. Enabled by default.
--subdir, --platform SUBDIR
Use packages built for this platform. The new environment will be configured to remember this
choice. Should be formatted like 'osx-64', 'linux-32', 'win-64', and so on. Defaults to the
current (native) platform.
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.
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
--shortcuts-only SHORTCUTS_ONLY
Install shortcuts only for this package name. Can be used several times.
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.
--console CONSOLE Select the backend to use for normal output rendering.
-v, --verbose Can be used multiple times. Once for detailed output, twice for INFO logging, thrice for DEBUG
logging, four times for TRACE logging.
-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
其他
1万+

被折叠的 条评论
为什么被折叠?



