Anaconda Use Summary (reprint)

Source: Internet
Author: User
Tags windows support
Preface

Python is easy to use, but it's not easy to work with, and the headaches are the problem of package management and different versions of Python, especially when you're using Windows. To address these issues, there are a number of distributions of Python, such as Winpython, Anaconda, and so on, which pack Python and many commonly used package to facilitate pythoners direct use, in addition to Virtualenv, Tools such as pyenv manage virtual environments.

The individual tried many similar distributions, eventually choosing Anaconda, because of its powerful and convenient package management and environmental management functions. This article mainly introduces the Anaconda, the understanding of Anaconda, and briefly summarizes the related operation. Anaconda Overview

Anaconda is a Python release for scientific Computing, supports Linux, MAC, Windows, and provides package management and environmental management capabilities to easily address multiple versions of Python coexistence, switching, and a variety of third-party package installation issues. Anaconda uses tools/command Conda for package and environment management, and already contains Python and related tools.

Here we first explain the differences between the concepts of Conda and Anaconda. Conda can be understood as a tool and an executable command whose core functions are package management and Environmental management . Package management is similar to the use of the PIP, and environmental management allows users to easily install different versions of Python and can switch quickly. Anaconda is a packaged collection of Conda, a version of Python, numerous packages, scientific computing tools, and so on, which is also known as a release of Python. In fact, there are Miniconda, as the name suggests, it contains only the most basic content--python and Conda, as well as the relevant must rely on, for the space requirements of users, Miniconda is a choice.

Before you go to the next section, explain the design concept of Conda-Conda treats almost all of the tools and Third-party packages as package, including Python and Conda itself . As a result, Conda has broken the constraints of package management and environmental management, and can easily install various versions of Python, various package, and easily switch. installation of Anaconda

Anaconda download page, Linux, MAC, Windows support.

When you install, you will find two different versions of Anaconda, corresponding to Python 2.7 and Python 3.5, and two versions in fact all the same except for this distinction. As we'll see later, it's not essential to install which version because we can easily switch the Python version of the runtime through environmental management. (Since my usual Python is 2.7 and 3.4, I tend to install Python 2.7 corresponding Anaconda directly)

After downloading directly follow the instructions to install it. Here's a caveat: try to install it as anaconda Default-without using root, for personal installation, the installation directory is set in the Personal home directory (Windows doesn't matter). The advantage is that different users on the same machine can install and configure their own anaconda without affecting each other.

For a Mac, Linux system, Anaconda installed, in fact, in the home directory more than a folder (~/anaconda) only, Windows will write to the registry. When installed, the installer adds the bin directory to the path (Linux/mac write ~/.bashrc,windows to the system variable path), which can be done entirely on its own. Take Linux/mac as an example, the operation of setting path after Setup is completed is

# Add the Anaconda Bin directory to PATH, depending on the version, it may also be ~/anaconda3/bin
echo ' Export path= ~/anaconda2/bin: $PATH ' ' >> ~/. BASHRC
# Update BASHRC for immediate effect
source ~/.BASHRC

After you have configured your path, you can check for correctness through the which Conda or Conda--version command. If a version of Python 2.7 is installed, running Python--version or python-v can get Python 2.7.12:: Anaconda 4.1.1 (64-bit), which also indicates that the default environment for the release is Python 2.7. Environmental management of Conda

Conda's environmental management capabilities allow us to install several different versions of Python at the same time and to switch freely. For the above installation process, assuming that we are using the Python 2.7 corresponding installation package, then Python 2.7 is the default environment (the default name is root, and note that this root is not meant for super administrators).

Let's say we need to install Python 3.4, and at this point we need to do the following:

# Create an environment named Python34 that specifies the Python version is 3.4 (3.4.x,conda will automatically find the latest version of 3.4.x for us)
Conda create--name python34 python=3.4

# After installation, use activate to activate an environment
activate Python34 # for Windows
source activate Python34 # for Linux & Mac
# After activation, you will find that terminal input more python34 words, in fact, at this time the system is to do is to remove the default 2.7 environment from the path, and then 3.4 corresponding command to join the path

# at this time, again input
python-- Version
# can get ' Python 3.4.5:: Anaconda 4.1.1 (64-bit) ', that the system has switched to 3.4 of the Environment

# if you want to return to the default Python 2.7 environment, run
Deactivate Python34 # for Windows
source Deactivate Python34 # for Linux & Mac

# Delete an existing environment
Conda remove --name Python34--all

The different Python environments that users install are placed under the directory ~/anaconda/envs and can be run Conda INFO-E view the installed environment in the command, and an asterisk or parenthesis is displayed in the currently activated environment.

Description: Some users may often use the Python 3.4 environment, so directly add the bin or scripts below the ~/ANACONDA/ENVS/PYTHON34 to the path and remove the anaconda corresponding Bin directory. This method, how to say, also can, but always feel not so elegant ...

If you follow the above mentioned so change path, you will find Conda command and can not find (of course, because Conda in ~/anaconda/bin), this time how to do it. The method has two: 1. Explicitly gives the absolute address of the Conda 2. The Conda tool (recommended) is also installed in the PYTHON34 environment. package management for Conda

Conda package management is better understood, and this part of the function is similar to the PIP.

For example, if you need to install SciPy:

# Install scipy
Conda install scipy
# Conda from remote search scipy related information and dependencies, for Python 3.4,conda installs both NumPy and MKL (compute-accelerated libraries)

# To view the packages
Conda List
# The latest version of the Conda is to search the Site-packages folder for installed packages, not on the PIP, so you can display packages installed in various ways

Some common operations of Conda are as follows:

# View installed packages in the current environment
Conda List

# View installed packages for a specified environment
Conda list-n python34

# Find package information
Conda Search numpy< c5/># installation package
Conda install-n python34
# If you do not use-N to specify the environment name, it is installed in the current active environment
# can also be specified through a NumPy installation

# Update package
Conda update-n python34 numpy

# Delete Package Conda remove-n python34 the NumPy

As mentioned earlier, Conda treats Conda, Python, and so on as package, so it is entirely possible to use Conda to manage versions of Conda and Python, such as

# update Conda, keep Conda latest
Conda update Conda

# Update anaconda
Conda update Anaconda

# update Python
Conda Update Python
# Assuming the current environment is Python 3.4, Conda will upgrade Python to the current latest version of the 3.4.x series

Add: If you create a new Python environment, such as 3.4, after running Conda create-n python34 python=3.4, Conda installs only Python 3.4-related required items such as Python, Pip, If you want the environment to install the Anaconda collection package like the default environment, you only need to:

# Install Anaconda Package Collection
Conda Install Anaconda # in the current environment

the command to create the environment can be combined into
Conda create-n python34 python=3.4 Anaconda
# can also not install all, according to the requirements of the installation of their own package can be
set up a domestic mirror

If you need to install a lot of packages, you will find that Conda downloads are often slow because anaconda.org servers are abroad. Fortunately, Tsinghua Tuna mirror source has anaconda warehouse mirroring, we will add it to the Conda configuration can:

# Add Anaconda Tuna Mirror
conda config--add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# The mirror address in Tuna's help is enclosed in quotes and needs to be removed

# set to display channel address
Conda config--set show_channel_urls Yes

After the above command is executed, a ~/.condarc (LINUX/MAC) or C:\Users\USER_NAME\.condarc file is generated, documenting our configuration of Conda, which is the same effect as manually creating and editing the file directly. sequence

Anaconda features Cross-platform, package management, and environmental management, so it's a good place to quickly deploy a Python environment on a new machine. In summary, the complete set of installation and configuration processes are as follows: Download anaconda, install configuration path (BASHRC or environment variable), change tuna mirror source to create the required version of the Python environment Just try!

Cheat-sheet Download:
Conda Cheat Sheet

Author: Peteryuan
Link: http://www.jianshu.com/p/2f3be7781451
Source: Jianshu
Copyright belongs to the author. Commercial reprint please contact the author to obtain authorization, non-commercial reprint please indicate the source.

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.