如何用conda解决不可写路径的问题? [英] How does one fix the issue of not writable paths with conda?
问题描述
为什么使用conda时通常会出现以下错误(通常是在安装软件包或制作新的env时)以及如何解决它:
Why do I see the following error when using conda (usually when installing packages or making new envs) 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
或
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
可以在以下gitissue上找到有关我所做工作的详细概述:
a detailed outline of what I did can be found on the following gitissue:
https://github.com/conda/conda/issues/7267
除了从头开始重新安装conda并运行以下命令外,这真的没什么花哨的:
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
它安装了此版本的conda:
and it installed this version of conda:
❯ conda -V
conda 4.7.12
引起警告的命令示例:
conda create -n myenv python=3.6
使用conda安装软件包时出现更多错误:
More errors when I install packages with conda:
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::openssl-1.1.1d-h1de35cc_3 --> conda-forge::openssl-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
我运行的
命令:
command that I ran:
(automl) brandomiranda~/automl-meta-learning ❯ conda install -c conda-forge jupyterlab
我尝试根据建议的答案更改权限,但似乎没有sudo无法正常工作.在这里做sudo真的安全吗?为什么它不能写给正确的用户集?
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
运行建议的答案后更新
我已经在sudo中运行了chmod命令.我检查了该文件的权限,然后得到以下信息:
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
我检查了此内容是因为我尝试使用conda install conda-build
命令安装conda-build
,但最终出现了错误:
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
看起来很奇怪,而且当我注意到environment.txt
与其他文件/目录没有相同的权限时.我也很想对该文件进行chmod修改,但是所有这些工作似乎都在解决这个问题.我觉得这本来不应该发生的,所以我会问:
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:
- 我们如何正确解决此问题?
- 应该如何安装conda(在使用zsh的Mac版新Catalina OS中)?
- 不管什么,
/Users/brandomiranda/.conda
conda文件夹的权限应该是什么?所有文件夹/文件都应具有相同的权限吗?
- 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 suppose to be and should all folders/files have the same permissions?
现在我将运行:
sudo chmod 775 /Users/brandomiranda/.conda/environments.txt
尽管如此,我不得不为与conda相关的内容运行sudo
而使我感到不安.有人知道如何在不使用sudo的情况下执行此操作吗?还是应该使用sudo?
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?
作为附带的评论,我很高兴从未尝试使用sudo从conda安装任何内容,而只是更改了一些文件夹/文件的权限.这似乎比允许conda在sudo中运行任意代码安全得多(相反,这里它可以在不以sudo运行时将其内容运行到特定位置,所以我想更改文件夹权限还不错吗?).
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?).
推荐答案
参考: https://gist .github.com/zoka123/f2b03f19924258d28441fe2d88750145
检查路径是否可写:
if [ -w "./.conda" ]; then echo "WRITABLE"; else echo "NOT WRITABLE"; fi
如果它不可写,则将可写性更改为任何人:
if it is not writable, change writability to anybody:
chmod 775 ./.conda
如果您对现有文件权限感到好奇:
If you are curious of existing file permission:
ls -lha
输出当前位置的访问权限集,其中d
是指当前目录.
例如:drwxr-xr-x
:
ls -lha
outputs the set of access right of current locations, where d
refers to current directory.
Eg: drwxr-xr-x
:
每个数字分别代表用户,组和全局的权限.对于以上示例,
rwx
表示当前用户可以读取,写入和执行; r-x
对于组和全局而言,这意味着它们只能读取和执行.
each digit refers to right for User, Group and Global respectively. For the above example,
rwx
means current user can read,write and execute; r-x
for both group and global, which means they can read and execute only.
chmod
与3位数字命令一起使用,对于上述三种类型的身份,每个数字均指的是read, write, execute
访问的一种组合.
chmod
is used with a 3-digit commands, each digit refers to one combination of the read, write, execute
access for the above three types of identity.
755
对于当前用户表示rwx
,对于组和全局表示r-x
.
755
means rwx
for current user, and r-x
for Group and Global.
您可以参考 https://www.linode.com/docs/tools-reference/tools/modify-file-permissions-with-chmod/供参考.
这篇关于如何用conda解决不可写路径的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!