Anaconda installation and use

Anaconda installation and use

The first part of "Python data analysis training"

Preface

As the saying goes, "Workers must first sharpen their tools if they want to do well." If we want to run Python code, we need a Python environment. This article will explain in detail the installation and use of anaconda.

Advantages of Anaconda

Normally, we go directly to the official Python website to install the environment, but why do I recommend you to use Anconda? 1. let's take a look at what Anaconda is:

Anaconda is an integrated Python data science environment. Simply put, in addition to Python, Anaconda also installs more than 180 third-party libraries for data analysis, and can use conda commands to install third-party libraries and create multiple environments. Compared with only installing Python, it avoids the trouble of installing third-party libraries.

Through the above description, we can simply say that Anaconda is a Python environment with many third-party libraries installed. It has two obvious advantages:

  • Easy to install library
  • Easy to create and manage environment
Anaconda installation

What we installed here is the Tsinghua mirror of Anaconda, the website is ( https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ ).

According to the computer system, choose the version installed by yourself. Here I am a windows system, 64-bit.

After downloading to the local, just run the installation. This is similar to most software installations. There are two things worth noting:

Because the computer may have multiple users, we select all users here.

The first option is to add anaconda to the computer's environment variables, it doesn't matter.

Anaconda use

In the start menu, find Anaconda Prompt. Open it and enter the Anaconda environment.

Enter Python and you can write Python code.

The creation of multiple environments: Here to remind novice friends, you must exit the Python editing environment before you can run the following code.

conda create --name xxx python=2 #xxx is the name of the environment, and an environment with python version 2 is created
conda create --name xxx python=3 #Created an environment with python version 3
conda create --name xxx python=3 anaconda #Created an environment with python version 3 and has all the packages of anaconda
conda info --envs #View environment
activate xxx #Activate the environment
deactivate xxx #Exit the environment
conda remove --name xxx --all # delete an existing environment

Package installation and uninstallation:

conda install xxx #xxx is the package name
conda remove xxx #Uninstall package
pip install xxx
pip uninstall xxx

Use of jupyter notebook: jupyter notebook is an editor, just like text can be written on stone, bamboo, or paper; Python code can also be written on different editors.

If we want to write the code in the folder named Code on the d drive, we need to go to the d drive first, and then cd to this path. Finally enter jupyter notebook, a web page will pop up, and you can write Python code as shown in the figure.

d:
cd d\code
jupyter notebook
Reference: https://cloud.tencent.com/developer/article/1414674 Anaconda Installation and Use-Cloud + Community-Tencent Cloud