Conda creates a virtual environment
1, what is a virtual environment
it is a virtualization, independent from computer hacked out of the environment. Commonly speaking, virtual environment is to use virtual machine Docker to independent part of the content, we call this part of independent things “container”, in this container, we can only install the dependent packages we need, each container is isolated from each other, do not affect each other.
2, why want to use a virtual environment
in the actual project development, we usually according to their own requirements to download all sorts of corresponding framework library, such as Scrapy, Beautiful Soup, etc., but may each project USES the framework of library is not the same, or using a framework version is different, so we need to according to the demand constantly update, or uninstall the corresponding libraries. Working directly with our Python environment can cause a lot of unnecessary hassle for our development environment and project, and can be quite confusing to manage. Like the following scene:
Scenario 1: Project A requires version 1.0 of A framework, and project B requires version 2.0 of the library. If the virtual environment is not installed, then when you use the two projects, you will have to uninstall back and forth, which can easily cause errors in your project.
Scenario 2: Your company’s previous projects need to run in Python 2.7, and your project needs to run in Python 3. If you do not use the virtual environment, you may not be able to use both projects at the same time. If you use Python 3, your company’s previous projects may not be able to run, and your new projects may have trouble running. If the virtual environment can configure different runtimes for the two projects, then both projects can run at the same time.
Second, conda common commands
in the Anaconda conda can be understood as a tool, is also an executable commands, its core function is package management and environmental management. Therefore, the virtual environment to create, delete and other operations need to use the conda command.
1. Create a virtual environment
conda create-n env_name numpy matplotlib python=2.7 # Conda create -n env_name numpy matplotlib python=2.7 #
2. Activate the virtual environment
Linux: source activate your_env_name
Windows: activate your_env_name
tivate root
p>n –version Check if the current Python version is the one you want.
3. Exit the virtual environment
Linux: Conda deactivate your_env_name
Windows: deactivate env_name
4. Remove the virtual environment
Conda remove-n your_env_name(virtual environment name) — ALL
Delete packages from virtual environment:
Conda remove –name $your_env_name $package_name
6. Share the environment
conda env export > environment.yml
7. Create the environment from the YML file
conda env create -f environment.yml
Conda install package_name
(4). Conda install package_name
(4). Conda install package_name
(4). Conda install package_name
(4).
(5). Conda update conda: Check to update the current conda.
(5)
Read More:
- Using CONDA virtual environment in pychar
- Jupyter notebook couldn’t find CONDA’s virtual environment
- For the installation of anaconda3 in manjaro system, after the update (CONDA update — all), the terminal prompts an error and cannot execute CONDA related commands
- RemoveError: ‘setuptools’ is a dependency of conda and cannot be removed from conda’s operatin
- RemoveError: ‘requests’ is a dependency of conda and cannot be removed from conda’s operating enviro
- RemoveError: ‘requests‘ is a dependency of conda and cannot be removed from conda‘s operating env
- Removeerror: ‘requests’ is a dependency of CONDA and cannot be removed from CONDA’s o
- conda install failed: conda.core.subdir_ data.Response304ContentUnchanged Python cannot be installed
- After canceling the startup of Ubuntu terminal, it will automatically enter the base environment of CONDA
- Solve CONDA’s “solving environment: failed” problem
- RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /opt/conda/conda-bld/
- CONDA upgrade command: upgrade CONDA, anaconda and various packages
- CONDA failed to create environment (collecting package metadata(repodata.json): failed)
- Error in downloading update creation environment of CONDA: collecting package metadata (current_ repodata.json): failed
- Stata external commands: the most common and up-to-date commands
- The python version output from the command line is inconsistent with the python version in the current CONDA environment
- Removeerror: ‘setuptools’ is a dependency of CONDA
- Invalid archiveerror reported by CONDA
- Common linux commands — find command’s Exec
- Package summary of installing python with CONDA