SoFunction
Updated on 2024-11-13

Graphic tutorial on changing the default path of anaconda virtual environment

I. View all virtual environments and their paths (conda env list)

Second, view the default location of the virtual environment (conda config --show)

What comes out slides down and slides to envs_dirs, where three paths are shown, the first being the default installation path for the virtual environment.

III. Adding environment paths (conda config --add envs_dirs D:/Environment_2023/Anaconda3/envs)

Assuming that the D-disk path is in the second position initially, and the .conda\envs path in the C-disk is in the first position (most of the time), the system defaults to installing the .conda\envs path in the C-disk (which has been a problem for many people). After executing the above code, the path of D disk will be changed to the first position, which will change the default path.

Ps: The above code is meant to add paths, but since the paths already existed, it was adjusted to the first position, and removing the paths corresponds to conda config --remove envs_dirs dir

IV. Try to create a new virtual environment (conda create -n Work37 python=3.7)

In the code, Work37 is the name of the virtual environment, followed by 3.7 for the version of python. Note that the system will ask you when creating the virtual environment, at this point, if as an attempt, you don't have to type y, just n, because the system has already told you the path to the installation. If you want to remove an environment you have already created, the code is (conda remove -n environment name --all).

V. Changing the properties of the Anaconda3 folder

If the above path has been changed to D disk (target disk), congratulations have been successful. If you are not sure, you can create your own virtual environment and check the path using (conda env list).

If you find that the path remains unchanged when you try to create the environment, don't worry, it's normal. The reason for this is a problem with the properties of the Anaconda3 folder.

Go to the Properties screen of Anaconda3 and click Security

Click to edit

Allow all permissions for Users (the last special permission may not be clickable, but it doesn't matter, just click the rest). After that, click OK, you may need to wait for a little while here, and then you are done.

VI. Change of owner

If you click OK in the above steps and get an error saying "An error occurred while applying security information to the following objects", don't worry, it is normal. In this case, you need to do the following steps:

Click Advanced in the Security screen

Click Change (you may need to give administrator rights, just do it)

Click on Advanced

Click to find out now

Find Everyone and click OK

Click OK

Check the boxes "Replace owners of child containers and objects" and "Replace permission items of all child objects with permission items that can be inherited from this object" and click OK. This may take a while, after finishing, in the repeat the steps in five, you will find that clicking OK no longer reports an error, the great success.

VII. conda clean -p

Adjust the path is to make room for the C disk, note that occasionally you can also use conda to clean up a little Oh, the role of this command is to delete useless packages, the figure on the existence of 2.76G of garbage, directly enter y can be deleted.

summarize

To this article on the anaconda virtual environment to change the default path of the article is introduced to this, more related to the default path of the anaconda virtual environment content, please search for my previous articles or continue to browse the following related articles I hope that you will support me more in the future!