Download Anaconda
Anaconda itself is an open source and free software. When downloading, you can directly search anaconda, visit the official website and enter the optional version interface
Pull to the bottom of the interface to select the version you want to download according to your system
After downloading, double-click the exe file to install it.
Note: try not to install it in Disk c, but in other larger disks.
During installation, please check "agree to add environment variables", which is useful later!!!!
Open the Anaconda command line after installation
Enter the instruction to create an environment name to be built in the hall
In the hall, Anaconda is not allowed to create an environment name with the same name, so it can build an independent small room to store its own environment
The code for creating a room is shown below.
// Create a separate room conda create -n pytorch python=3.7 //Create means create //-n means name //Pytorch means the name of the created room. Here I use pytorch, //You can also use a name you are familiar with and easy to remember //python=3.7 means that I want to preset a bottom Python 3 environment in this room
Enter the room from the hall
It can be seen that anaconda will not automatically enter the created room and is still in the base environment. The previous picture also shows how to enter the created room.
// Enter room (active) conda activate pytorch // Exit the room conda deactivate
View the list of bags already packed in the room
After entering the room, we can check which bags are in the room
conda list
There is no pytorch yet
Install pytorch into the room
pytorch, torch also means torch. It's not very different from tensorflow. It depends on the individual
If the above command line is copied directly, it will be downloaded through the pytorch official website by default, but it may take a long time for foreign servers to be installed.
The following describes how to modify Anaconda's default download source. Through Tsinghua source or university of science and technology source.
//Tsinghua source: conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ conda config --set show_channel_urls true //China University of science and technology source: conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/ conda config --set show_channel_urls yes
Tsinghua source. After copying, click enter and then press enter to add it
China University of science and technology source, click enter after copying, and then press enter to add it
See which source is preferred or which sources have been added
// View source conda config --show-source
// Install pytorch using domestic source, or copy the code just on the official website, but delete - c and the following contents conda install pytorch torchvision torchaudio cpuonly
There are some endogenous in package countries that have not been updated
Use the address of the original official website
// Less common conda install pytorch torchvision torchaudio cpuonly -c pytorch
Enter y to start downloading. If the network is unstable and some packages fail to download, you can execute the above instructions again for downloading and installation. It may take a long time here.
See which rooms are in the base environment
// Enter the following command to exit to the base Hall conda deactivate // See which rooms are available conda info -e // Select the room you want to enter conda activate pytorch
Verify that pytorch is installed in the room
Execute python
Import torch
Success indicates that pytorch has been installed
Delete room in lobby
// Return to lobby delete conda remove -n XXX --all // XXX indicates the name of the room to be deleted // --all delete everything in it
Import the newly established environment into pycharm
Similarly, download the software on pycharm's official website and open it after successful installation. After creating a new project, change its compiler to the python 3 interpreter in Python just established in Anaconda.
Click settings
Click on the gear
Click ADD
Select conda to create a new one or select an existing one
After modification, you can see
You can install the desired package to the room at the terminal
conda install XXX
Jupiter notebook editor
This is Anaconda's own editor. It is opened in the form of a web page. You can click to open it, as shown in the figure
Jupyter is an interactive editor that can display the results in real time. Pychart needs to be put together before it can be displayed
Another Jupiter notebook needs to be installed in the room
// Installing in pytorch conda install jupyter notebook
The above operations refer to the video of the UP Master of station b, which can be viewed together with the video. The links are as follows
Installation video: Video Explanation.