相关文章推荐
仗义的苹果  ·  Pycharm 中 ...·  6 天前    · 
重情义的数据线  ·  Conda 创建 Python ...·  5 天前    · 
失望的扁豆  ·  频谱图 - 知乎·  1 年前    · 
坚强的椅子  ·  php mongodb aggregate ...·  1 年前    · 
聪明伶俐的蛋挞  ·  kotlin - Moshi: ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to update Anaconda and its packages using conda update --name root conda , but it fails every time.

Error message : EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: C:\ProgramData\Anaconda3

Environment location: C:\ProgramData\Anaconda3 . I replaced the root with base , still I get the same error.

Any help?

Maybe you could give some more details about your environment and the versions of software that might be pertinent to the question to help anyone who might be able to help you. Damo Mar 21, 2019 at 22:46 In addition, in more recent versions of conda (for the last 1.5 years or so) the main environment is called base , not root . darthbith Mar 22, 2019 at 0:42 environment location: C:\ProgramData\Anaconda3. I replaced the root with base. I get the same error A. E. Fahim Mar 22, 2019 at 20:58 When installing packages, this error can occur if you have forgot to first activate your environment. (Not your issue exactly but it may help other people with who have that issue and find this question.) HelloGoodbye Jun 7, 2022 at 12:46 This is not correct. At least under Linux/Mac OS conda is not supposed to require super user rights. lumbric Sep 25, 2019 at 9:24 It worked for me on Windows 10. I haven't tried on Mac, but I would try running the command as sudo conda update --name root conda. Bremsstrahlung Dec 7, 2019 at 21:47 @hamedbaziyad yes, it might be considered as workaround and might solve your problem, but running conda with super user rights should not be necessary in many cases and is probably not the best thing to do in these cases. Running commands with super user rights can cause more damage than without, so it is always better to avoid super user rights. Also users might not have super user rights but still want to update conda. lumbric Dec 16, 2019 at 12:28 On Windows, if you're trying to install packages into the base environment (which is installed to C:\ProgramData\Anaconda3 ), you'll need admin access. If you first create an environment (which should install in your user directory under .conda\envs) and activate it, you no longer need admin right for that environment. Don't forget to activate the env after creating it. C.J. Jackson May 11, 2021 at 19:18

If you face this issue in Linux, one of the common reasons can be that the folder "anaconda3" or "anaconda2" has root ownership. This prevents other users from writing into the folder. This can be resolved by changing the ownership of the folder from root to "USER" by running the command:

sudo chown -R $USER:$USER anaconda3

or sudo chown -R $USER:$USER <path of anaconda 3/2 folder>

Note: How to figure out whether a folder has root ownership? -- There will be a lock symbol on the top right corner of the respective folder. Or right-click on the folder->properties and you will be able to see the owner details

The -R argument lets the $USER access all the folders and files within the folder anaconda3 or anaconda2 or any respective folder. It stands for "recursive".

Worked for me. However, I think you need to change the ownership of ~/.conda as well since it contains, for example, environments.txt which needs to be updated. – user118967 Dec 20, 2019 at 1:01 Where is the anaconda folder typically located? If you are on a computer shared with other people, such as a server, is this solution really recommended? – HelloGoodbye Jun 7, 2022 at 9:22

On Windows, search for Anaconda PowerShell Prompt. Right click the program and select Run as administrator. In the command prompt, execute the following command:

conda update -n base -c defaults conda

Your Anaconda should now update without admin related errors.

Can you tell me why, when I run conda update -n base -c defaults conda it says Warning: A newer version of conda exists please run conda update -n base -c defaults conda? Keeps me amused for hours.... – Stephen Ellwood Mar 16 at 10:56

If you get this error under Linux when running conda using sudo, you might be suffering from bug #7267:

When logging in as non-root user via sudo, e.g. by:

sudo -u myuser -i

conda seems to assume that it is run as root and raises an error.

The only known workaround seems to be: Add the following line to your ~/.bashrc:

unset SUDO_UID SUDO_GID SUDO_USER

...or unset the ENV variables by running the line in a different way before running conda.

If you mistakenly installed anaconda/miniconda as root/via sudo this can also lead to the same error, then you might want to do the following:

sudo chown -R username /path/to/anaconda3

Tested with conda 4.6.14.

I had installed anaconda via the system installer on OS X in the past, which created a ~/.conda/environments.txt owned by root. Conda could not modify this file, hence the error.

To fix this issue, I changed the ownership of that directory and file to my username:

sudo chown -R $USER ~/.conda

On Windows in general, running command prompt with administrator works. But if you don't want to do that every time, specify Full control permissions of your user (or simply all users) on Anaconda3 directory. Be aware that specifying it for all users allows other users to install their own packages and modify the content.

I had the same issue and the base environment was in C:\ProgramData\Anaconda3. This is the case, when Anaconda is installed for all users.

As a solution, I re-installed Anaconda just for me and now the base environment is in \AppData\Local\Continuum\anaconda3. This now can be updated via conda update without admin privileges.

I believe this answer is out of date. I installed only for local user (myself) not all users and I am still having the same issue. – brethvoice Dec 31, 2021 at 3:34

Reason

Sometimes for creating a virtual env at a specified location other than the pre-defined path at ~/anaconda3/envs we append the conda config file using: conda config --append envs_dirs /path/to/envs where envs_dirs is a specified function in config file for allocating different paths where conda can find your virtual envs. Removing a recently added path in this config file may solve the problem.

Solution

$:> conda config --show envs_dirs
    envs_dirs:
    - /home/some_recent_path    # remove this
    - /home/.../anaconda3/envs

Note the value specifing a different directory other than the predefined location, and remove it using

$:> conda config --remove envs_dirs /home/some_recent_path

Now the config file envs_dirs is set to default location of envs. Try creating a new env now.

WINDOWS: I also got following error while (base) PS E:\Python> conda install ConfigParser

Verifying transaction: failed

EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: C:\ProgramData\Anaconda3

My solution: Open Command prompt as administrator, then above command again and it worked.

C:\WINDOWS\system32>conda install ConfigParser

Collecting package metadata (current_repodata.json): done Solving environment: done

Package Plan

environment location: C:\ProgramData\Anaconda3

added / updated specs: - configparser

The following NEW packages will be INSTALLED:

configparser pkgs/main/noarch::configparser-5.0.2-pyhd3eb1b0_0

Proceed ([y]/n)? y

Preparing transaction: done Verifying transaction: done Executing transaction: done

As mentioned in a comment to the accepted answer, the default environment base requires administrative rights on Windows:

On Windows, if you're trying to install packages into the base environment (which is installed to C:\ProgramData\Anaconda3), you'll need admin access. If you first create an environment (which should install in your user directory under .conda\envs) and activate it, you no longer need admin right for that environment. Don't forget to activate the env after creating it. – C.J. Jackson

In my case somehow CONDA_ENVS_PATH was removed, so I was having NotWritableError. So I fixed the error by specifying

CONDA_ENVS_PATH=~/my-envs:/opt/anaconda/envs

in the .bashrc file

  • Press the Windows+S combination button and type "cmd" into it.
  • Right click on the Command Prompt App result that shows up and click on "Run as administrator"
  • Now, in the black window that is open (i.e. your Command prompt), copy and paste the following to check for your version: conda --version
  • If you want the latest update, then update Conda by running the update command by pasting the following and clicking enter in the command prompt(black window): conda update conda
  • If a newer version is available, it will prompt you for a yes/no to install the update. Type "yes" and then press Enter to update.
  • This is a bad idea: won't work for most people most of the time, and could remove some necessary configuration options. – Denise Draper Mar 8, 2021 at 7:30