Anaconda + Pycharm, use Anaconda to install python and configure the virtual environment, including the installation of sklearn and pytorch

Preface: Before installation, if your computer name contains Chinese, please rename your computer first, remember not to bring Chinese, otherwise you may make mistakes.

Explanation: I use this set for in-depth learning. If we are the same, you can read it. It is also a reference value if it is different.

This article does not include the installation tutorial of pycharm!

Anaconda is mainly for the convenience of subsequent package imports. After installing Anaconda, you can have python and Jupyter Notebook without additional downloads, and many deep learning teachings are displayed in Jupyter Notebook.

Pycharm is also a very popular python compiler, which I'm used to.


Text: This article is divided into three parts: Anaconda download , configuration of virtual environment variables and pycharm new project .

1. Anaconda download

1. First, go to the Anaconda mirror website and choose to download the Anaconda version according to your own system. The Anaconda mirror website is as follows:

https://mirrors.bfsu.edu.cn/anaconda/archive/

It is recommended to choose the 2022.10 version like me, because I have not tried the others, so I can't guarantee it.

2. After downloading, double-click the exe file, and then there are three key forks

(1) Just me and All Users, select Just me

(2) Change the installation path by yourself, do not install it on the C drive. Remember, it will be used later.

(3) Do not select Add ... to PATH at the last fork, only select the option of Register, as shown in the figure:

( We will manually add environment variables later , don't panic)

The rest of the next is fine, just wait for the installation to complete.

3. Next, manually add environment variables

Open this interface (right click - display settings, you should be able to come out), search for environment variables in the search box, and select Edit system environment variables

 In the pop-up interface, select the environment variable

Under System Variables below, select Path and click Edit

 In the pop-up interface, select New, and then add the circled 3 paths as environment variables. This is determined according to your custom Anaconda installation path. You can refer to the interface shown in the picture I gave.

Path one interface:

Path two interface:

Path three interfaces:

After setting up the environment variables, remember to confirm, and then the Anaconda installation is complete.

After the Anaconda installation is complete, you can first check the conda configuration to confirm whether the default installation path of the package is under the envs folder of the custom installation path:

conda info

或 conda config –show

 # There are three lines in the red box, the first line is your custom Anaconda installation path

If you are not, but the second line in my red box, in the position of your first line, you need to change the default installation path of the package to:

conda config –add envs_dirs D:\Anaconda\Anaconda3_2022_10\envs

# This should be changed to the envs folder path under your Anaconda

After I download it, I don't need to change the default installation path of the package.


2. Configure virtual environment variables

1. Open the start menu, find the newly downloaded Anaconda Navigator , and click Open

2. First, select Environments on the left; then, click Create in the lower left corner to create a virtual environment;

Next, select the Python version, I chose the 3.7.16 version, because the latest version of python is not compatible with some packages (if you have downloaded python before, but there is no one here, it doesn’t matter, you can choose it directly, and it will be downloaded automatically a version of python) ;

Finally, give your virtual environment a famous name, such as mine: envs_3_7_16 See the picture below for details.

3. Then install some commonly used packages for deep learning

First, change Installed to Not installed. Then, search for the package you want to install in the search box on the right. After I have installed it here, I will not show the picture. After searching, select the one with the same name as Apply and it will be ok.

Commonly used deep learning packages are: numpy, pandas, matplotlib, pymysql, sklearn and pytorch ( I use pytorch)

The necessary three-piece set: numpy, pandas and matplotlib are used to process matrices, organize tabular data and draw and display respectively;

pymysql: with pandas, it can be used to read the data stored in the mysql database;

sklearn: necessary for machine learning, and can also be used for data preprocessing of deep learning;

pytorch: One of the deep learning tools.

It is worth noting! ! !

You can't find it by searching directly in sklearn. It is not in Anaconda. If you want to install it, see below.

Before installing sklearn, you need to import:

(1)numpy + mkl  (2)scipy

And mkl will already be installed with numpy when installing numpy through Anaconda , so there is no need to install it additionally . Therefore, we only need to search for scipy installation in Not installed. After installing scipy, you can install sklearn. The steps to install sklearn are as follows:

Open the start menu, click on the icon Anaconda Powershell Prompt

and then this interface

First enter: conda activate + your virtual environment name. For example: I should enter here: conda activate envs_3_7_16

After pressing Enter, enter: pip install scikit-learn

If there is successfully in the prompt, it will be installed. (If pip prompts you to upgrade, just follow the prompts to upgrade the pip version)

# Here scikit-learn is the full name of sklearn


Three, pycharm new project

First, select the location of the project and customize the path; then, select the previously configured interpreter for the python interpreter; uncheck the create main.py welcome script at the bottom; click on the right to enter the python interpreter selection interface . As shown below:

After entering the selection interface, select the Conda environment, click on the right side again at the interpreter, as shown in the figure below:

Select python.exe in the envs folder in the Anaconda installation directory, and then create it, please refer to the following figure:

Create a new python file, and the package import test did not report an error. success~~

 

It is not easy to make, if it is useful, please support it more.

Guess you like

Origin blog.csdn.net/learninger_lt7/article/details/130793048