How to configure and install Anaconda in win

Source: Internet
Author: User
Tags jupyter jupyter notebook
This time to bring you how to configure and install Anaconda in win, in Win configuration and installation of Anaconda notes, the following is the actual case, together to see.

First, download anaconda

The first step of course is to download anaconda, the official website of the download need to use Thunder to hurry

Choose the appropriate version to download it.

In addition to the installation location, there are two places to be confirmed during the download process.

The first tick is whether to add Anaconda environment variables, which involves the ability to use the CMD directly in the Conda, Jupyter, Ipython and other commands, recommended tick, if not tick the question is not very small, you can use the Anaconda provided by the command line tool to operate The second is whether to set Anaconda Python 3.6 as the default Python version of the system, which is not a problem to look at.

Once the installation is complete, you can open cmd to test the installation results.

Enter Python, Ipython, Conda, Jupyter notebook and other commands, and you will see the corresponding results, indicating that the installation was successful. (Python is entered into the Python interactive command line; Ipython is the Ipython interactive command line, very powerful; Conda is the Anaconda Configuration command; Jupyter notebook will start the web-side Ipython Notebook)

It is important to note that the Jupyter Notebook command starts the Jupyter service locally on the computer with the default configuration, which is discussed later.

After the Anaconda installation is successful, we need to modify its package management image as a domestic source.

Second, configure the image address, or download the upgrade file from the official website too slow

After the installation is complete, locate the Anaconda prompt, add the mirror address, and complete the configuration:

Conda Config--add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
Conda Config--set show_channel_urls Yes

On Windows, a batch of applications will be installed with Anaconda:

    • Anaconda Navigator, which is a GUI for managing environments and packages

    • Anaconda Prompt terminal, which allows you to use the command line interface to manage environments and packages

    • The Spyder, which is the IDE for scientific development

To avoid errors, I recommend updating all packages in the default environment. Open Anaconda Prompt (or the terminal under Mac), type:

conda upgrade --all

and enter Y (Yes) When prompted to update, so that the update continues. The initial installation of the package version is generally older, so early update can avoid future unnecessary problems.

Management Pack

After the Anaconda is installed, the Management Pack is fairly straightforward. To install the package, type it in the terminal conda install package_name . For example, to install NumPy, type conda install numpy .

You can also install multiple packages at the same time. conda install numpy scipy pandas A similar command installs all of these packages at the same time. You can also specify the desired package version by adding a version number (for example conda install numpy=1.10 ).

Conda will also automatically install dependencies for you. For example, SCIPY relies on numpy because it is used and requires numpy. If you install only scipy (Conda install scipy), Conda will also install NumPy if it is not already installed.

Most of the commands are intuitive. To uninstall a package, use the conda remove package_name . To update your package, use the conda update package_name . If you want to update all the packages in your environment (this is often useful), use the conda update --all . Finally, to list the installed packages, use the previously mentioned conda list .

If you do not know the exact name of the package you are looking for, you can try searching using it conda search search_term . For example, I know I want to install Beautiful Soup, but I don't know the exact package name. Therefore, I try to execute conda search beautifulsoup .

Search BeautifulSoup

It returns a list of available Beautiful Soup packages and lists the corresponding package name BEAUTIFULSOUP4.

Managing the Environment

As mentioned earlier, you can use Conda to create an environment to isolate projects. To create an environment, use Conda create-n env_name List of packages in the terminal. Here,-n Env_name sets the name of the environment (-n refers to the name), and list of packages is the listing of packages to be installed in the environment. For example, to create an environment named My_env and install NumPy in it, type conda create -n my_env numpy .

When you create an environment, you can specify the version of Python that you want to install in your environment. This is useful when you are using the code in Python 2.x and Python 3.x at the same time. To create an environment with a specific Python version, type a command similar to conda create -n py3 python=3 or conda create -n py2 python=2 . In fact, I created these two environments on my personal computer. I use them as a common environment unrelated to any particular project to handle normal work (each Python version can be easily used). These commands will install the latest versions of Python 3 and Python 2, respectively. To install a specific version (for example, Python 3.3), use the conda create -n py python=3.3 .

Into the environment

Once the environment has been created, use the source activate my_env enter environment on the Osx/linux. On Windows, please use the activate my_env .

After entering the environment, you will see the environment name in the terminal prompt, which is similar to (MY_ENV) ~ $. There are only a few default packages installed in the environment, and the packages that you installed when you created it. You can use the Conda list to check this out. The command to install the package in the environment is the same as before: conda install package_name . However, the specific package you install this time is only available when you enter the environment. To leave the environment, type source deactivate (on Osx/linux). On Windows, please use the deactivate .

Save and load the environment

Sharing the environment is really useful, it allows others to install all the packages that are used in your code, and ensures that the packages are in the correct version. You can save the package as YAML using Conda env export > Environment.yaml. The first part of the command, Conda env export, is used to export the names of all packages in the environment, including the Python version.

Exporting an exported environment to a terminal

, you can see the name of the environment and all dependencies and their versions. The second part of the Export command > Environment.yaml writes the exported text to the Yaml file Environment.yaml. You can now share this file, and other people can use it to create the same environment as your project.

To create an environment from your environment file, use the Conda env create-f Environment.yaml. This creates a new environment, and it has the same libraries that are listed in Environment.yaml.

List environment

If you forget the name of the environment (which I sometimes do), you can use the conda env list list of all the environments that you created. You'll see a list of environments, and you'll have an asterisk next to your current environment. The default environment (that is, the environment that you use when you are not in the selected environment) is named Root.

Delete an environment

If you no longer use certain environments, you can use conda env remove -n env_name the delete specified environment (named Env_name here).

Use environment

A great help to me is that my Python 2 and Python 3 have a separate environment. I used the Conda create-n py2 python=2 and Conda create-n py3 python=3 to create two separate environments, namely Py2 and Py3. Now, every Python version of me has a common environment. In all of these environments, I have installed most of the standard data science packages (NumPy, scipy, pandas, etc.).

I also found it useful to create an environment for every project I work on. This is also useful for projects that are not related to data, such as WEB apps that are developed using Flask. For example, I created an environment for my personal blog (using Pelican).

Shared environment

When sharing code on GitHub, it's a good idea to create an environment file and include it in the code base as well. This will make it easier for others to install all of your code's dependencies. For users who do not use Conda, I usually use PIP freeze (see here for details) to export and include a PIP Requirements.txt file.

Continue to add:

The configuration is complete and you can play happily.

Input: conda list View the packages that were installed

Test it:

To switch the current environment:

Current is Python3, if you switch to 2.7, enter

conda create -n python2 python=2.7

Input:

activate python2

Complete the environment switch

Add:

Conda Common Commands
View the environment under the current system
Conda INFO-E
Create a new environment
# Specify a python version of 2.7
Conda create-n Python2 python=2.7
# Install the necessary packages at the same time
Conda create-n python2 numpy matplotlib python=2.7
Environment switch
# LINUX/MAC requires the use of source activate Python2
Activate Python2
#退出环境
Deactivate Python2
Removing an environment
Conda remove-n Python2--all

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

Python operator Matrix column

Python operations Excel read and write data

Unittest+coverage How to perform unit test coverage

Related Article

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.