Anaconda installation and uninstallation Python virtual environment configuration

Tip: After the article is written, the table of contents can be automatically generated. For how to generate it, please refer to the help document on the right.

Article directory

  • Preface
  • 1. Anaconda download
  • 2. Anaconda installation steps
  • 3. Building a python virtual environment under Anaconda management (command line)
    • Open Anaconda Prompt
    • Commands related to building a python virtual environment.
    • Pycharm combined with Anaconda
  • 4. Completely uninstall Aaconda
    • Administrator runs Anaconda Aprompt
    • Run the Anaconda uninstaller
    • Residual cleaning
      • Tool recommendation—[everything](https://www.voidtools.com/zh-cn/downloads/)
  • Summarize

Foreword

Tip: Here is the general content to be recorded in this article:

I have configured the anaconda environment many times, and each time I refer to the tutorials of other experts on csdn and search again, which is quite troublesome, so I simply write a configuration tutorial by myself.
This article does not talk about the principles, but only simple operation steps and certain code demonstrations, focusing on practicality.

Tips: The following is the text of this article

1. Anaconda download

  • Official website download address: https://www.anaconda.com/download
  • Just click to download.
    Generally, for novices, just use the latest version;
    For veterans, I think they all have experience.
  • Be patient and wait.

2. Anaconda installation steps

  1. Double-click the installation package and click next
    Installation package diagram

  2. Just click “I agree”. If your English is pretty good, you can give it a try and read the content.

  3. Both are acceptable. If there is a user switch, select “ALL Users” and click “Next”. After that, a prompt picture will pop up. Just select Yes. Since the picture cannot be taken, the picture will not be uploaded.

  4. Under normal circumstances, software like this is not recommended to install the C drive unless the C drive is very large. I always click Browse and select another path. As you can see in the picture below, I changed the installation path to the G drive.

  5. If it has been installed before and uninstalls and reinstalls, it is recommended to select ③ and then click “install”.

  6. The installation is over here, and a picture of the installation completion will appear without interception.

  7. However, there will be a problem, that is, the automatic configuration of environment variables may fail, and manual configuration is required. It is also very simple. Use the search box to search for “Edit System Environment Variables” to open it, and click “Environment Variables“.

  8. Double-click “Path” in “System Variables”.

  9. Click New, a blue frame will appear at the bottom, then click Browse, find the following five paths and add them according to your own installation path. For example, if my anaconda is installed under the learn path under the G drive, then it is G: learn\anaconda3
    etc.

    G:\anaconda3
    
    G:\anaconda3\Library\mingw-w64\bin
    
    G:\anaconda3\Library\usr\bin
    
    G:\anaconda3\Library\bin
    
    G:\anaconda3\Scripts
    
    



The installation is basically over here, except for some new problems that may be encountered (which I have not encountered).

3. Building a python virtual environment under Anaconda management (command line)

Open Anaconda Prompt

Search for "Anaconda Prompt" in the computer application search bar and run it as an administrator. A confirmation box will pop up, just click "Yes".
 Then you can see the base environment, and then you can use the command line to build the environment.


Commands related to building a python virtual environment.

/* View python virtual environment,
You can see your virtual environment name and path */
conda env list

/* "Your name" is usually in English, and the following python=3.9 specifies the python version.
You can also not specify it, and the default version will be installed. */
conda create -n your environment name python=3.9

/* If it is a newly created environment, you will be prompted with this command to activate the virtual environment. You can activate it first, and then pip the software package */
conda activate your environment name

conda deactivate /* Exit the current python environment*/

conda remove -n your environment name --all /* delete your virtual environment */

/* Just download the python package. Personally, I prefer to use pip.
For example, pytorch and the pytorch official website will have corresponding pip formats, so don’t worry about not knowing how to do it */
pip install package name

Pycharm combined with Anaconda

  • After opening your project, click “File” and then “Settings.”
    Please add image description
  • Click “Project Control“, then click “Add Interpreter“, add “Local Interpreter“, and select Conda Environment strong>, among which G:anacodna3\_conda.exe may not be found. You need to enter it manually, and then click to load the environment (the first time you enter it, or it will be loaded by default after you enter it), then Then select the environment you have created in the drop-down box. In my case, it is “yanshi”.
    Please add image description
  • Next, you can run code that does not require other python packages normally, but if you want to use the numpy package, run anaconda prompt as an administrator and then pip.
    Please add image description
    After setting up the environment, it can be used normally.

4. Complete uninstall of Aaconda

The administrator runs Anaconda Aprompt

/* Download anaconda-clean */
conda install -c anaconda anaconda-clean
/* Execute anaconda cleanup */
anaconda-clean --yes

Run the Anaconda uninstaller

Find Unistall-Anaconda3.exe in your anaconda installation path, right-click and run as administrator.

Remnant cleaning

  • Tool recommendation-everything

    • You can use the green version without installation, just give it enough permissions.
      Then open everything and search for “Anaconda”,
      If the Anaconda-related files are not on the C drive, feel free to delete them;
      If it is on the C drive, delete it selectively after considering the English language.
  • The uninstallation is basically completed here. After reinstallation, it should be able to run normally. If it still doesn’t work after reinstallation, you should consider finding the registry to delete it. I haven’t found a good method yet

Summary

  • This article briefly describes the downloading, installation, uninstallation, configuration and establishment of the python environment of Anaconda. If there is a better method, it will be updated in time.
    These are some methods that have been compiled recently. They are for reference only. Please give us your valuable suggestions for revision.