Creating a Python virtual environment with Conda

Source: Internet
Author: User
Tags virtual environment

anaconda+ Creating a Python virtual environment with Conda the difference between Anaconda and Conda

Conda can be understood as a tool and an executable command whose core function is package management and environmental management. Package management is similar to the use of PIP, and environmental management allows users to easily install different versions of Python and switch quickly. Conda's design philosophy --conda almost all of the tools, third-party packages are treated as a package, even Python and Conda itself Anaconda is a packaged collection, loaded with Conda, One version of Python, many packages, scientific computing tools, and so on.

1, first install anaconda in the system. You can open the command line to enter CONDA-V to verify the installation and the current Conda version.

2, Conda commonly used commands.

1) Conda list to see which packages are installed.

2) Conda env list or Conda info-e see what virtual environments are currently present

3) Conda update Conda Check for current Conda

3. Create a Python virtual environment.

Use the Conda create-n your_env_name python=x.x (2.7, 3.6, etc.) Anaconda command to create a Python version of x.x and a virtual environment named Your_env_name. The Your_env_name file can be found under the Anaconda installation directory Envs file.

# 指定python版本为2.7,注意至少需要指定python版本或者要安装的包# 后一种情况下,自动安装最新python版本conda create -n env_name python=2.7# 同时安装必要的包conda create -n env_name numpy matplotlib python=2.7

4. Use a virtual environment that activates (or toggles between different Python versions).

Open the command line input Python--version to check the current Python version.

Use the following command to activate your virtual environment (the version of Python will change).

Linux:source Activate Your_env_name (Virtual environment name)

Windows:activate your_env_name (Virtual environment name)

This is again using Python--version to check if the current Python version is desired.

5. Install additional packages in the virtual environment.

Install the package to your_env_name using the command Conda install-n your_env_name

6. Close the virtual environment(即从当前环境退出返回使用PATH环境中的默认python版本)。

Use the following command.

deactivate env_name,也可以使用`activate root`切回root环境
Linux下使用 source deactivate

7. Delete the virtual environment.

    • Removing an environment

   使用命令conda remove -n your_env_name(虚拟环境名称) --all, 即可删除。

    • Deletes a package in the environment.

Use the command conda remove--name $your _env_name $package _name.

8, set the domestic mirror

If you need to install a lot of packages, you will find that Conda download is often very slow, because anaconda.org server is abroad. Fortunately, the Tsinghua tuna image source has a anaconda warehouse image, we add it to the Conda configuration:

# Add Anaconda tuna Mirror Conda config--add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/# Tuna Help in the mirror address with quotation marks, need to remove the # Set search display channel Address Conda config--set show_channel_urls Yes

  

 

Resources:

http://blog.csdn.net/lyy14011305/article/details/59500819

https://zhuanlan.zhihu.com/p/22678445

Anaconda 4.2---Conda use (Windows)

Anaconda Usage Summary

Creating a Python virtual environment with Conda

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.