conda官网文档参考链接:https://conda.io/projects/conda/en/latest/index.html
本文把文档中一些我觉得比较有用的知识搬运一下,以便之后查阅
Concepts一节都是一些Conda中用到的常见概念,Getting started with conda一节中是一些比较实用的操作,想看conda命令直接跳到该节即可
The fastest way to obtain conda is to install Miniconda, a mini version of Anaconda that includes only conda and its dependencies. If you prefer to have conda plus over 7,500 open-source packages, install Anaconda.
where python
.which python
.Conda is an open-source package management system and environment management system. Conda quickly installs, runs, and updates packages and their dependencies. Conda easily creates, saves, loads, and switches between environments on your local computer. With just a few commands, you can set up a totally separate environment to run that different version of Python, while continuing to run your usual version of Python in your normal environment.
The conda
command is the primary interface for managing installations of various packages.
Tip: You can abbreviate many frequently used command options that are preceded by 2 dashes (–) to just 1 dash and the first letter of the option. So --name and -n are the same, and --envs and -e are the same.
A conda package is a compressed tarball file (.tar.bz2) or .conda file that contains:
The .conda file format was introduced in conda 4.7 as a more compact, and thus faster, alternative to a tarball.
When a conda package is used for metadata alone and does not contain any files, it is referred to as a metapackage. The metapackage may contain dependencies to several core, low-level libraries and can contain links to software files that are automatically downloaded when executed. Metapackages are used to capture metadata and make complicated package specifications simpler.
The Anaconda metapackage collects together all the packages in the Anaconda installer. The command conda create -n envname anaconda creates an environment that exactly matches what would be created from the Anaconda installer.
在我的电脑里,所有包都存在D:\Software\Anaconda3\pkgs
目录下
.
├── bin
│ └── pyflakes
├── info
│ ├── LICENSE.txt
│ ├── files
│ ├── index.json
│ ├── paths.json
│ └── recipe
└── lib
└── python3.5
The info/ directory contains all metadata about a package.
Lib/site-packages/torchvision-0.6.0-py3.7.egg-info/PKG-INFO
Lib/site-packages/torchvision-0.6.0-py3.7.egg-info/SOURCES.txt
Lib/site-packages/torchvision-0.6.0-py3.7.egg-info/dependency_links.txt
Lib/site-packages/torchvision-0.6.0-py3.7.egg-info/not-zip-safe
Lib/site-packages/torchvision-0.6.0-py3.7.egg-info/requires.txt
Lib/site-packages/torchvision-0.6.0-py3.7.egg-info/top_level.txt
...
{
"arch": "x86_64",
"build": "py37hfa4b5c9_1",
"build_number": 1,
"depends": [
"depend > 1.1.1"
],
"license": "BSD 3-Clause",
"name": "fun-packge",
"platform": "linux",
"subdir": "linux-64",
"timestamp": 1535416612069,
"version": "0.0.0"
}
D:\Software\Anaconda3\Lib\site-packages
目录下{
"paths": [
{
"_path": "lib/python3.7/site-packages/fun-packge/__init__.py",
"path_type": "hardlink",
"sha256": "76f3b6e34feeb651aff33ca59e0279c4eadce5a50c6ad93b961c846f7ba717e9",
"size_in_bytes": 2067
},
{
"_path": "lib/python3.7/site-packages/fun-packge/__config__.py",
"path_type": "hardlink",
"sha256": "348e3602616c1fe4c84502b1d8cf97c740d886002c78edab176759610d287f06",
"size_in_bytes": 87519
},
...
}
A cloud-based repository that contains 7,500+ open-source certified packages that are easily installed locally with the conda install
command.
Conda channels are the locations where packages are stored. They serve as the base for hosting and managing packages. Conda packages are downloaded from remote channels, which are URLs to directories containing conda packages. The conda
command searches a default set of channels, and packages are automatically downloaded and updated from https://repo.anaconda.com/pkgs/. You can modify what remote channels are automatically searched.
A conda environment is a directory that contains a specific collection of conda packages that you have installed. For example, you may have one environment with NumPy 1.7 and its dependencies, and another environment with NumPy 1.6 for legacy testing. If you change one environment, your other environments are not affected. You can easily activate or deactivate environments, which is how you switch between them. You can also share your environment with someone by giving them a copy of your environment.yaml
file.
ROOT_DIR
: The directory that Anaconda or Miniconda was installed into.
/pkgs
: Also referred to as PKGS_DIR. This directory contains decompressed packages, ready to be linked in conda environments.
/envs
: The system location for additional conda environments to be created.
The following subdirectories comprise the default Anaconda environment:
/bin
/include
/lib
/share
Other conda environments usually contain the same subdirectories as the default environment.
Conda’s performance can be affected by a variety of things. Unlike many package managers, Anaconda’s repositories generally don’t filter or remove old packages from the index. This allows old environments to be easily recreated. However, it does mean that the index metadata is always growing, and thus conda becomes slower as the number of packages increases.
Conda Provides commonly used data science libraries and tools, such as R, NumPy, SciPy, and TensorFlow. These are built using optimized, hardware-specific libraries (such as Intel’s MKL or NVIDIA’s CUDA) which speed up performance without code changes.
conda config --set safety_checks disabled
.conda config --set channel_priority strict
.conda clean --all
conda --help
OR
conda -h
EXAMPLE: To see help for the create command, in your terminal window or an Anaconda Prompt, run:
conda create -h
SEE ALSO: Getting started with Anaconda Navigator, a graphical user interface that lets you use conda in a web-like interface without having to enter manual commands.
Verify that conda is installed and running on your system by typing:
conda --version
OR
conda info
Update conda to the current version. Type the following:
使用这个命令的时候千万要注意不能断网!!!不然conda可能就要出错了~网络不好者慎用。本人亲身经历,update到一半突然断网,之后conda update这个命令就疯狂报错
conda update conda
We recommend that you always keep conda updated to the latest version.
When you begin using conda, you already have a default environment named base
. You don’t want to put programs into your base environment, though. Create separate environments to keep your programs isolated from each other.
# name the environment myenv and install the package scipy
# This environment uses the same version of Python that you are currently using because you did not specify a version.
conda create --name myenv scipy=0.15.0
# create an environment with a specific version of Python
conda create -n myenv python=3.6 scipy=0.15.0 astroid babel
# Create the environment from the environment.yml file
conda env create -f environment.yml
The first line of the yml
file sets the new environment’s name.
conda activate myenv
Activation entails two primary functions: adding entries to PATH for the environment and running any activation scripts that the environment may contain. These activation scripts are how packages can set arbitrary environment variables that may be necessary for their operation.
Now that you are in your myenv environment, any conda commands you type will go to that environment until you deactivate it.
conda info --envs
conda env list
conda activate
The conda activate
command prepends the path of your current environment to the PATH environment variable so that you do not need to type it each time. deactivate
removes it. Even when an environment is deactivated, you can still execute programs in that environment by specifying their paths directly, as in ~/anaconda/envs/envname/bin/program_name
. When an environment is activated, you can execute the program in that environment with just program_name
.
conda list -n myenv
conda list
conda list -n myenv scipy
# create a new environment in a subdirectory of the current working directory called envs
conda create --prefix ./envs jupyterlab=0.35 matplotlib=3.1 numpy=1.16
# activate an environment created with a prefix
conda activate ./envs
There are a few things to be aware of when placing conda environments outside of the default envs
folder.
After activating an environment using its prefix, your prompt will look similar to the following:
(/absolute/path/to/envs) $
This can result in long prefixes:
(/Users/USER_NAME/research/data-science/PROJECT_NAME/envs) $
To remove this long prefix in your shell prompt, modify the env_prompt setting in your .condarc
file:
$ conda config --set env_prompt '({name})'
update the contents of your environment.yml
file accordingly and then run the following command:
# The --prune option causes conda to remove any dependencies that are no longer required from the environment.
$ conda env update --prefix ./env --file environment.yml --prune
conda create --name myclone --clone myenv
Export an environment with exact package versions for one OS
conda list --explicit
to produce a spec list such as:# This file may be used to create an environment using:
# $ conda create --name --file
# platform: osx-64
@EXPLICIT
https://repo.anaconda.com/pkgs/free/osx-64/mkl-11.3.3-0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/numpy-1.11.1-py35_0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/openssl-1.0.2h-1.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/pip-8.1.2-py35_0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/python-3.5.2-0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/readline-6.2-2.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/setuptools-25.1.6-py35_0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/sqlite-3.13.0-0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/tk-8.5.18-0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/wheel-0.29.0-py35_0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/xz-5.2.2-0.tar.bz2
https://repo.anaconda.com/pkgs/free/osx-64/zlib-1.2.8-3.tar.bz2
An explicit spec file is not usually cross platform, and therefore has a comment at the top such as # platform: osx-64
showing the platform where it was created.
conda list --explicit > spec-file.txt
conda create --name myenv --file spec-file.txt
conda install --name myenv --file spec-file.txt
Conda does not check architecture or dependencies when installing from a spec file. To ensure that the packages work correctly, make sure that the file was created from a working environment, and use it on the same architecture, operating system, and platform, such as linux-64 or osx-64.
Export an environment to a YAML file that can be read on Windows, macOS, and Linux
# This file handles both the environment's pip packages and conda packages.
conda env export --name ENVNAME > environment.yml
conda env export --from-history
This will only include packages that you’ve explicitly asked for, as opposed to including every package in your environment.
For example, if you create an environment and install Python and a package:
conda install python=3.7 codecov
This will download and install numerous additional packages to solve for dependencies. This will introduce packages that may not be compatible across platforms.
If you use conda env export
, it will export all of those packages. However, if you use conda env export --from-history
, it will only export those you specifically chose:
(env-name) ➜ ~ conda env export --from-history
name: env-name
channels:
- conda-forge
- defaults
dependencies:
- python=3.7
- codecov
prefix: /Users/username/anaconda3/envs/env-name
name: stats2
channels:
- javascript
dependencies:
- python=3.6 # or 2.7
- bokeh=0.9.2
- numpy=1.9.*
- nodejs=0.10.*
- flask
- pip:
- Flask-Testing
Note the use of the wildcard * when defining the patch version number. Defining the version number by fixing the major and minor version numbers while allowing the patch version number to vary allows us to use our environment file to update our environment to get any bug fixes whilst still maintaining consistency of software environment.
conda env create --file envname.yml
Create an environment from the file named environment.yml in the current directory
conda env create
Conda keeps a history of all the changes made to your environment, so you can easily “roll back” to a previous version. To list the history of each change to the current environment: conda list --revisions
To restore environment to a previous revision: conda install --revision=REVNUM
or conda install --rev REVNUM
.
Example: If you want to restore your environment to revision 8, run conda install --rev 8
.
conda remove --name myenv --all
You may instead use conda env remove --name myenv
.
When you create a new environment, conda installs the same Python version you used when you downloaded and installed Anaconda(For the installers “Anaconda3” or “Miniconda3,” the default is 3.7).
conda search python
# anaconda is the metapackage that includes all of the Python packages comprising the Anaconda distribution
conda create -n py36 python=3.6 anaconda
If you are in an environment with Python version 3.4.2, the following command updates Python to the latest version in the 3.4 branch:
conda update python
The following command upgrades Python to another branch—3.6—by installing that version of Python:
conda install python=3.6
“Virtual” packages are injected into the conda solver to allow real packages to depend on features present on the system that cannot be managed directly by conda, like system driver versions or CPU features. Virtual packages are not real packages and not displayed by conda list
.
The currently supported list of virtual packages includes:
__cuda
: Maximum version of CUDA supported by the display driver.__osx
: OSX version if applicable.__glibc
: Version of glibc supported by the OS.conda info
If a package is detected, you will see it listed in the virtual packages
section, as shown in this example:
active environment : base
active env location : /Users/demo/dev/conda/devenv
shell level : 1
user config file : /Users/demo/.condarc
populated config files : /Users/demo/.condarc
conda version : 4.6.3.post8+8f640d35a
conda-build version : 3.17.8
python version : 3.7.2.final.0
virtual packages : __cuda=10.0
base environment : /Users/demo/dev/conda/devenv (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/osx-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/osx-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/demo/dev/conda/devenv/pkgs
/Users/demo/.conda/pkgs
envs directories : /Users/demo/dev/conda/devenv/envs
/Users/demo/.conda/envs
platform : osx-64
user-agent : conda/4.6.3.post8+8f640d35a requests/2.21.0 CPython/3.7.2 Darwin/17.7.0 OSX/10.13.6
UID:GID : 502:20
netrc file : None
offline mode : False
The following command adds the channel “new_channel” to the top of the channel list, making it the highest priority:
conda config --add channels new_channel
Conda has an equivalent command:
conda config --prepend channels new_channel
Conda also has a command that adds the new channel to the bottom of the channel list, making it the lowest priority:
conda config --append channels new_channel
国内的源(使用清华大学开源软件镜像站):
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
还有一些用得上的深度学习框架(百度飞浆和pytorch)
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
We use conda-forge as an example channel. Conda-forge is a community channel made up of thousands of contributors. Conda-forge itself is analogous to PyPI but with a unified, automated build infrastructure and more peer review of recipes.
conda install scipy --channel conda-forge
specify multiple channels by passing the argument multiple times(Priority decreases from left to right - the first argument is higher priority than the second):
conda install scipy --channel conda-forge --channel bioconda
only search the specified channel(s), rather than any channels configured in .condarc. This also ignores conda’s default channels.
conda search scipy --channel file:/<path to>/local-channel --override-channels
conda search beautifulsoup4
conda search --override-channels --channel http://conda.anaconda.org/mutirri iminuit
conda install python=3.4
. Internally, python=3.4 is translated to python 3.4*.
Package dependencies are specified using a match specification. A match specification is a space-separated string of 1, 2, or 3 parts:
special characters | example |
---|---|
| means OR | 1.0 | 1.2 matches version 1.0 or 1.2 |
* matches 0 or more characters in the version string | 1.4* matches 1.4 and 1.4.1b2… |
<, >, <=, >=, == and != | <=1.0 matches 0.9, 0.9.1, and 1.0 |
, means AND | >=2,< 3 matches all packages in the 2 series |
, has higher precedence than |, so >=1,<2|>3 means greater than or equal to 1 AND less than 2 or greater than 3
Remember that the version specification cannot contain spaces, as spaces are used to delimit the package, version, and build string in the whole match specification. python >= 2.7 is an invalid match specification.
When using the command line, put double quotes around any package version specification that contains the space character or any of the following characters: <, >, *, or |.
conda install numpy=1.11 # matches 1.11, 1.11.0, 1.11.1, 1.11.2, 1.11.18, and so on.
conda install numpy==1.11 # matches 1.11, 1.11.0, 1.11.0.0, and so on.
conda install "numpy>1.11"
conda install "numpy=1.11.1|1.11.3"
conda install "numpy>=1.8,<2"
conda install --name myenv scipy
conda install scipy
conda install scipy=0.15.0
conda install scipy curl
conda list
Installing packages directly from the file does not resolve dependencies.
conda install /path-to-package/package-filename.tar.bz2/
Packages that are not available using conda install
can be obtained from Anaconda.org, a package management service for both public and private package repositories.
To install a package from Anaconda.org:
bottleneck
in the top-left box named Search Packages.conda install -c pandas bottleneck
If a package is not available from conda or Anaconda.org, you may be able to find and install the package via conda-forge or with another package manager like pip.
Pip packages do not have all the features of conda packages and we recommend first trying to install any package with conda. If the package is unavailable through conda, try finding and installing it with conda-forge.
If you still cannot install the package, you can try installing it with pip. The differences between pip and conda packages cause certain unavoidable limits in compatibility but conda works hard to be as compatible with pip as possible.
To list all of the packages in the active environment:
conda list
To list all of the packages in a deactivated environment:
conda list -n myenv
# update to the latest compatible version
conda update biopython
conda update python
conda update conda
Conda updates to the highest version in its series, so Python 2.7 updates to the highest available in the 2.x series and 3.6 updates to the highest available in the 3.x series.
Example:
If Python 2.7.0 is currently installed, and the latest version of Python 2 is 2.7.5, then conda update python installs Python 2.7.5. It does not install Python 3.5.2.
If Python 3.4.0 is currently installed, and the latest version of Python is 3.5.2, then conda install python=3 installs Python 3.5.2.
conda update
always installs the highest version with the same major version number, whereas conda install
always installs the highest version.
conda update conda
conda update anaconda
Update all packages to the latest version of Anaconda. Will install stable and compatible versions, not necessarily the very latest.
conda config --add create_default_packages PACKAGENAME1 PACKAGENAME2
You can also edit the .condarc file with a list of packages to create by default.
You can override this option at the command prompt with the --no-default-packages
flag.
conda remove -n myenv scipy
conda remove scipy
conda remove scipy curl
The conda configuration file .condarc
is an optional runtime configuration file that allows advanced users to configure various aspects of conda, such as which channels it searches for packages, proxy settings, and environment directories. For all of the conda configuration options, see the configuration page.
The .condarc
file is not included by default, but it is automatically created in your home directory the first time you run the conda config
command.
The .condarc
configuration file follows simple YAML syntax.
conda config --add channels conda-forge
Alternatively, you can open a text editor. Name the new file .condarc
and save it to your user home directory or root directory. To edit the .condarc
file, open it from your home or root directory and make edits in the same way you would with any other text file. If the .condarc
file is in the root environment, it will override any in the home directory.
You can find information about your .condarc
file by typing conda info
in your terminal or Anaconda Prompt. This will give you information about your .condarc
file, including where it is located.
You can also download a sample .condarc file to edit in your editor and save to your user home directory or root directory.
To set configuration options, edit the .condarc
file directly or use the conda config --set
command.
conda config --set auto_update_conda False
For a complete list of conda config commands, use the conda config --help
command or see the command reference.You can also see the conda channel configuration for more information.
Conda looks in the following locations for a .condarc
file:
if on_win:
SEARCH_PATH = (
'C:/ProgramData/conda/.condarc',
'C:/ProgramData/conda/condarc',
'C:/ProgramData/conda/condarc.d',
)
else:
SEARCH_PATH = (
'/etc/conda/.condarc',
'/etc/conda/condarc',
'/etc/conda/condarc.d/',
'/var/lib/conda/.condarc',
'/var/lib/conda/condarc',
'/var/lib/conda/condarc.d/',
)
SEARCH_PATH += (
'$CONDA_ROOT/.condarc',
'$CONDA_ROOT/condarc',
'$CONDA_ROOT/condarc.d/',
'~/.conda/.condarc',
'~/.conda/condarc',
'~/.conda/condarc.d/',
'~/.condarc',
'$CONDA_PREFIX/.condarc',
'$CONDA_PREFIX/condarc',
'$CONDA_PREFIX/condarc.d/',
'$CONDARC',
)
CONDA_ROOT
is the path for your base conda install. CONDA_PREFIX
is the path to the current active environment.
conda config --show
channels:
- <anaconda_dot_org_username> # Non-URL channels are interpreted as Anaconda.org user names
- http://some.custom/channel
- file:///some/local/directory
- defaults # Use defaults to automatically include all default channels.
To select channels for a single environment, put a .condarc
file in the root directory of that environment (or use the --env
option when using conda config
).
Normally the defaults channel points to several channels at the repo.anaconda.com repository, but if default_channels
is defined, it sets the new list of default channels.
default_channels:
- http://some.custom/channel
- file:///some/local/directory
Whenever you use the -c
or --channel
flag to give conda a channel name that is not a URL, conda prepends the channel_alias
to the name that it was given. The default channel_alias
is https://conda.anaconda.org.
If channel_alias
is set to https://my.anaconda.repo:8080/conda/, then a user who runs the command conda install -c conda-forge some-package
will install the package some-package from https://my.anaconda.repo:8080/conda/conda-forge.
By default, conda prefers packages from a higher priority channel over any version from a lower priority channel. Therefore, you can now safely put channels at the bottom of your channel list to provide additional packages that are not in the default channels and still be confident that these channels will not override the core package set.
To make conda install the newest version of a package in any listed channel:
channel_priority: false
to your .condarc
file.conda config --set channel_priority false
When creating new environments, add the specified packages by default. You can override this option at the command prompt with the --no-default-packages
flag. The default is to not include any packages.
conda create --no-default-packages -n myenv python
create_default_packages:
- pip
- ipython
- scipy=0.15.0
By default, conda install
updates the given package to the latest version and installs any dependencies necessary for that package. However, if dependencies that satisfy the package’s requirements are already installed, conda will not update those packages to the latest version.
In this case, if you would prefer that conda update all dependencies to the latest version that is compatible with the environment, set update_dependencies
to True
.
The default is False
.
update_dependencies: True
Specify directories in which environments are located. If this key is set, the root prefix envs_dir
is not used unless explicitly included. This key also determines where the package caches are located.
For each envs here, envs/pkgs
is used as the pkgs cache, except for the standard envs
directory in the root directory, for which the normal root_dir/pkgs
is used.
envs_dirs:
- ~/my-envs
- /opt/anaconda/envs
Specify directories in which packages are located. If this key is set, the root prefix pkgs_dirs
is not used unless explicitly included.
pkgs_dirs:
- /opt/anaconda/pkgs
This setting controls whether or not conda activates your base environment when it first starts up. You’ll have the conda
command available either way, but without activating the environment, none of the other programs in the environment will be available until the environment is activated with conda activate base
.
It may be necessary to add the “force” option -f to the following commands.
To get all keys and their values:
conda config --get
To get the value of a specific key, such as channels:
conda config --get channels
To add a new value, such as http://conda.anaconda.org/mutirri, to a specific key, such as channels:
conda config --add channels http://conda.anaconda.org/mutirri
To remove an existing value, such as http://conda.anaconda.org/mutirri from a specific key, such as channels:
conda config --remove channels http://conda.anaconda.org/mutirri
To remove a key, such as channels, and all of its values:
conda config --remove-key channels
You can use your .condarc
file or environment variables to add configuration to control the number of threads. You may want to do this to tweak conda to better utilize your system. If you have a very fast SSD, you might increase the number of threads to shorten the time it takes for conda to create environments and install/remove packages.
repodata_threads
verify_threads
execute_threads
default_threads
At your terminal:
conda config --set repodata_threads 2
In .condarc
:
verify_threads: 4
conda install argcomplete
Add the following code to your bash profile:
eval "$(register-python-argcomplete conda)"
Issues may arise when using pip and conda together.
The conda 4.6.0 release added improved support for interoperability between conda and pip. This feature is still experimental and is therefore off by default.
With this interoperability, conda can use pip-installed packages to satisfy dependencies, cleanly remove pip-installed software, and replace them with conda packages when appropriate.
conda config --set pip_interop_enabled True # This may slow down conda
If there’s some software that needs to be found on PATH (you run it via the CLI), we recommend that you create your own batch files to set PATH dynamically within a console session, rather than permanently modifying PATH in the system settings.
For example, a new conda prompt batch file that first strips PATH, then calls the correct activation(activation prepends the conda environment PATH entries, they have priority) procedure could look like:
set
PATH=”%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;<3rd-party-entries>”
call “<miniconda/anaconda root>\Scripts\activate”
如果想在windows命令行里使用的话,直接运行下面指令即可:
D:\Software\Anaconda3\Scripts\activate
当然也可以手动在环境变量的PATH里添加以下路径:
不过最简单的还是直接用Anaconda Prompt,它会自动添加PATH路径同时运行激活脚本
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation.
If you receive this warning, you need to activate your environment. To do so on Windows, run: c:\Anaconda3\Scripts\activate base
Windows is extremely sensitive to proper activation. This is because the Windows library loader does not support the concept of libraries and executables that know where to search for their dependencies (RPATH). Instead, Windows relies on a dynamic-link library search order.
If environments are not active, libraries won’t be found and there will be lots of errors.
Conda itself includes some special workarounds to add its necessary PATH entries. This makes it so that it can be called without activation or with any child environment active. In general, calling any executable in an environment without first activating that environment will likely not work.
conda info # Verify that conda is installed
conda search beautifulsoup4
conda update conda # Update conda to the current version
conda update python
conda install python=3.6
conda update conda # update the Anaconda metapackage
conda update anaconda
conda install scipy --channel conda-forge --channel bioconda
conda install --name myenv scipy
conda install scipy=0.15.0
conda install scipy curl
conda install -c pandas bottleneck # Installing packages from Anaconda.org
conda remove -n myenv scipy
conda remove scipy curl
conda list -n myenv / conda list # Viewing a list of the packages in an environment
conda list -n myenv scipy # To see if a specific package is installed in an environment
conda config --add create_default_packages PACKAGENAME1 PACKAGENAME2
conda create -n py36 python=3.6 anaconda
conda create -n myenv python=3.6 scipy=0.15.0 astroid babel
conda env create -f environment.yml
conda env update --file environment.yml --prune # Updating an environment
conda env create # Create an environment from the file named environment.yml in the current directory
conda activate myenv
conda activate # Change your current environment back to the default (base)
conda info –envs / conda env list # see a list of all your environments
conda create --name myclone --clone myenv # Cloning an environment
conda env export --name ENVNAME --from-history > environment.yml
conda create --name myclone --clone myenv
conda list --revisions
conda install --revision=REVNUM / conda install --rev REVNUM
conda remove --name myenv –all / conda env remove --name myenv
conda config --add channels new_channel / conda config --prepend channels new_channel # adds the channel “new_channel” to the top of the channel list, making it the highest priority
conda config --append channels new_channel # adds the new channel to the bottom of the channel list, making it the lowest priority
conda config --remove channels http://conda.anaconda.org/mutirri
conda config --remove-key channels # To remove a key, such as channels, and all of its values
conda config --get channels # To get the value of a specific key, such as channels
国内的源(使用清华大学开源软件镜像站):
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
还有一些用得上的深度学习框架(百度飞浆和pytorch)
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config –show
conda config –get # To get all keys and their values