[Python] How to fix not writable paths with conda

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    Why do I see the following error when using conda? (usually when installing packages or making new envs, e.g. conda create -n myenv python=3.6) and how do I fix it?

    Verifying transaction: | WARNING conda.core.path_actions:verify(963): Unable to create environments file. Path not writable.
    environment location: /Users/brandomiranda/.conda/environments.txt


    or

    Preparing transaction: done
    Verifying transaction: - WARNING conda.core.path_actions:verify(963): Unable to create environments file. Path not writable.
    environment location: /Users/brandomiranda/.conda/environments.txt

    done
    Executing transaction: - WARNING conda.core.envs_manager:register_env(52): Unable to register environment. Path not writable or missing.
    environment location: /Users/brandomiranda/miniconda3/envs/myenv
    registry file: /Users/brandomiranda/.conda/environments.txt
    done


    a detailed outline of what I did can be found on the following git issue:

    NotWritableError: The current user does not have write permissions to a required path. #7267

    which really isn't anything too fancy except re-install conda from scratch and run the following command:

    bash Miniconda3-latest-MacOSX-x86_64.sh


    and it installed conda 4.7.12 (per conda -V)

    More errors when I install packages with conda


    (automl) brandomiranda~/automl-meta-learning ❯ conda install -c conda-forge jupyterlab
    Collecting package metadata (current_repodata.json): done
    Solving environment: done

    ## Package Plan ##

    environment location: /Users/brandomiranda/miniconda3/envs/automl

    added / updated specs:
    - jupyterlab


    The following packages will be downloaded:

    package | build
    ---------------------------|-----------------
    jupyter_client-5.3.4 | py37_0 131 KB conda-forge
    ------------------------------------------------------------
    Total: 131 KB

    The following NEW packages will be INSTALLED:

    appnope conda-forge/osx-64::appnope-0.1.0-py37_1000
    attrs conda-forge/noarch::attrs-19.3.0-py_0
    backcall conda-forge/noarch::backcall-0.1.0-py_0
    bleach conda-forge/noarch::bleach-3.1.0-py_0
    decorator conda-forge/noarch::decorator-4.4.1-py_0
    defusedxml conda-forge/noarch::defusedxml-0.6.0-py_0
    entrypoints conda-forge/osx-64::entrypoints-0.3-py37_1000
    importlib_metadata conda-forge/osx-64::importlib_metadata-1.3.0-py37_0
    ipykernel conda-forge/osx-64::ipykernel-5.1.3-py37h5ca1d4c_0
    ipython conda-forge/osx-64::ipython-7.11.1-py37h5ca1d4c_0
    ipython_genutils conda-forge/noarch::ipython_genutils-0.2.0-py_1
    jedi conda-forge/osx-64::jedi-0.15.2-py37_0
    jinja2 conda-forge/noarch::jinja2-2.10.3-py_0
    json5 conda-forge/noarch::json5-0.8.5-py_0
    jsonschema conda-forge/osx-64::jsonschema-3.2.0-py37_0
    jupyter_client conda-forge/osx-64::jupyter_client-5.3.4-py37_0
    jupyter_core conda-forge/osx-64::jupyter_core-4.6.1-py37_0
    jupyterlab conda-forge/noarch::jupyterlab-1.2.4-py_0
    jupyterlab_server conda-forge/noarch::jupyterlab_server-1.0.6-py_0
    libsodium conda-forge/osx-64::libsodium-1.0.17-h01d97ff_0
    markupsafe conda-forge/osx-64::markupsafe-1.1.1-py37h0b31af3_0
    mistune conda-forge/osx-64::mistune-0.8.4-py37h0b31af3_1000
    more-itertools conda-forge/noarch::more-itertools-8.0.2-py_0
    nbconvert conda-forge/osx-64::nbconvert-5.6.1-py37_0
    nbformat conda-forge/noarch::nbformat-5.0.3-py_0
    notebook conda-forge/osx-64::notebook-6.0.1-py37_0
    pandoc conda-forge/osx-64::pandoc-2.9.1.1-0
    pandocfilters conda-forge/noarch::pandocfilters-1.4.2-py_1
    parso conda-forge/noarch::parso-0.5.2-py_0
    pexpect conda-forge/osx-64::pexpect-4.7.0-py37_0
    pickleshare conda-forge/osx-64::pickleshare-0.7.5-py37_1000
    prometheus_client conda-forge/noarch::prometheus_client-0.7.1-py_0
    prompt_toolkit conda-forge/noarch::prompt_toolkit-3.0.2-py_0
    ptyprocess conda-forge/noarch::ptyprocess-0.6.0-py_1001
    pygments conda-forge/noarch::pygments-2.5.2-py_0
    pyrsistent conda-forge/osx-64::pyrsistent-0.15.7-py37h0b31af3_0
    python-dateutil conda-forge/noarch::python-dateutil-2.8.1-py_0
    pyzmq pkgs/main/osx-64::pyzmq-18.1.0-py37h0a44026_0
    send2trash conda-forge/noarch::send2trash-1.5.0-py_0
    terminado conda-forge/osx-64::terminado-0.8.3-py37_0
    testpath conda-forge/noarch::testpath-0.4.4-py_0
    tornado conda-forge/osx-64::tornado-6.0.3-py37h0b31af3_0
    traitlets conda-forge/osx-64::traitlets-4.3.3-py37_0
    wcwidth conda-forge/noarch::wcwidth-0.1.8-py_0
    webencodings conda-forge/noarch::webencodings-0.5.1-py_1
    zeromq conda-forge/osx-64::zeromq-4.3.2-h6de7cb9_2
    zipp conda-forge/noarch::zipp-0.6.0-py_0

    The following packages will be UPDATED:

    ca-certificates pkgs/main::ca-certificates-2019.11.27~ --> conda-forge::ca-certificates-2019.11.28-hecc5488_0

    The following packages will be SUPERSEDED by a higher-priority channel:

    certifi pkgs/main --> conda-forge
    openssl pkgs/main::eek:penssl-1.1.1d-h1de35cc_3 --> conda-forge::eek:penssl-1.1.1d-h0b31af3_0



    Proceed ([y]/n)? y


    Downloading and Extracting Packages
    jupyter_client-5.3.4 | 131 KB | ################################################################################################################################################################# | 100%
    Preparing transaction: done
    Verifying transaction: | WARNING conda.core.path_actions:verify(963): Unable to create environments file. Path not writable.
    environment location: /Users/brandomiranda/.conda/environments.txt

    done
    Executing transaction: - WARNING conda.core.envs_manager:register_env(52): Unable to register environment. Path not writable or missing.
    environment location: /Users/brandomiranda/miniconda3/envs/automl
    registry file: /Users/brandomiranda/.conda/environments.txt
    done

    chmod


    I tried changing the permission according to the suggested answers, BUT it seems it won't work without sudo. Is it really safe to do sudo here? why isn't it writable to the correct set of users already?

    (automl) brandomiranda~/.conda ❯ if [ -w "/Users/brandomiranda/.conda" ]; then echo "WRITABLE"; else echo "NOT WRITABLE"; fi
    NOT WRITABLE
    (automl) brandomiranda~/.conda ❯ chmod 775 /Users/brandomiranda/.conda
    chmod: Unable to change file mode on /Users/brandomiranda/.conda: Operation not permitted

    Update after running suggested answers


    I've ran the chmod command in sudo. I checked the permissions of that file and I got the following:

    (automl-meta-learning) brandomiranda~/automl-meta-learning/automl/automl ❯ ls -lha /Users/brandomiranda/.conda
    total 8
    drwxrwxr-x 3 root staff 96B Jan 5 16:57 .
    drwxr-xr-x+ 117 brandomiranda staff 3.7K Jan 19 17:25 ..
    -rw-r--r-- 1 root staff 32B Jan 5 16:57 environments.txt


    I checked this because I tried to install conda-build with conda install conda-build command but got the error towards the end:

    Preparing transaction: done
    Verifying transaction: \ WARNING conda.core.path_actions:verify(963): Unable to create environments file. Path not writable.
    environment location: /Users/brandomiranda/.conda/environments.txt
    done
    Executing transaction: \ WARNING conda.core.envs_manager:register_env(52): Unable to register environment. Path not writable or missing.
    environment location: /Users/brandomiranda/miniconda3/envs/automl-meta-learning
    registry file: /Users/brandomiranda/.conda/environments.txt done


    which seemed weird and that when I notice the environment.txt didn't have the same permissions as the other file/directories. I am tempted to chmod that file too but all this business seems to be putting a bandage on the problem. I feel this shouldn't have happened in the first place so I will ask:

    • How do we fix this properly?
    • How is one suppose to install conda (in the new Catalina OS for Mac using zsh)?
    • Regardless of anything, what are the permissions of the /Users/brandomiranda/.conda conda folder supposed to be and should all folders/files have the same permissions?

    for now I will run:

    sudo chmod 775 /Users/brandomiranda/.conda/environments.txt


    although, it makes me uneasy that I am having to run sudo for conda related stuff. Anyone know how to do this without requiring sudo or is sudo supposed to be required?

    As a side comment, I am glad I never tried installing anything from conda using sudo and only changed the permissions of a few folders/files. That seems much safer than allowing conda to run arbitrary code in sudo (instead here it can run its stuff to a specific location while NOT running in sudo, so I guess changing folder permissions isn't that bad?).

    Continue reading...

Compartilhe esta Página