Anaconda Sudo PIP 权限问题
Anaconda Sudo PIP permissions Problems
我正在学习 Python 并安装了 Anaconda,我正在尝试熟悉获取 Eye-Color Detection project working 的过程。
在完成自述文件后,我 运行 遇到以下错误:
Eye-Color-Detection git:(master) ✗ sudo pip install -r requirements.txt
WARNING: The directory '/Users/{user}/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
尝试更新时:
(tweet) ➜ Eye-Color-Detection git:(master) ✗ conda update --all
[Errno 13] Permission denied: '/Users/{user}/opt/anaconda3/envs/tweet/lib/python3.8/site-packages/wrapt/__init__.py' -> '/Users/{user}/opt/anaconda3/envs/tweet/lib/python3.8/site-packages/wrapt/__init__.py.c~'
问:我怎样才能在同一个 Conda 环境中正确地执行此操作?
您需要做的是将目录权限更改为writable
。
你可以使用这个命令来完成,
$ sudo chmod 7777 /Users/{user}/library/caches/
递归更改权限,
$ sudo chmod 7777 -R /Users/{user}/library/caches/
或者您可以使用此命令拥有该目录,
$ sudo chown OWNER:GROUP /Users/{user}/library/caches/
其中 OWNER
是您计算机的用户名,您可以使用此命令在终端中找到它。
$ whoami
GROUP
是可选的。
大多数时候,sudo pip install
几乎不是您真正想要的。虽然在某些情况下,它可能“看起来”有效并解决了您眼前的问题。通常情况下,您只是在不知情的情况下破坏了系统 python。
在那个 repo 的上下文中,我会忽略 repo 的自述文件并执行此操作。
$ git clone https://github.com/ghimiredhikura/Eye-Color-Detection
$ cd Eye-Color-Detection
创建virtualenv环境,yourenvname
随便改
$ conda create -n yourenvname python=3.x
$ conda activate yourenvname
安装依赖项和运行代码
$ pip install -r requirements.txt
$ python3 eye-color.py --input_path=sample/2.jpg --input_type=ima
因为修复你的 conda 环境可能很难调试,这取决于你 sudo
在尝试解决你的问题时还有什么。如果您碰巧熟悉使用 python 的内置虚拟环境工具创建的“常规”virtualenv,那么您也可以尝试使用此工具。
$ python3 -m venv .venv --copies
$ source .venv/bin/active
$ pip install -r requirements.txt
$ python3 eye-color.py --input_path=sample/2.jpg --input_type=image
我正在学习 Python 并安装了 Anaconda,我正在尝试熟悉获取 Eye-Color Detection project working 的过程。 在完成自述文件后,我 运行 遇到以下错误:
Eye-Color-Detection git:(master) ✗ sudo pip install -r requirements.txt
WARNING: The directory '/Users/{user}/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
尝试更新时:
(tweet) ➜ Eye-Color-Detection git:(master) ✗ conda update --all
[Errno 13] Permission denied: '/Users/{user}/opt/anaconda3/envs/tweet/lib/python3.8/site-packages/wrapt/__init__.py' -> '/Users/{user}/opt/anaconda3/envs/tweet/lib/python3.8/site-packages/wrapt/__init__.py.c~'
问:我怎样才能在同一个 Conda 环境中正确地执行此操作?
您需要做的是将目录权限更改为writable
。
你可以使用这个命令来完成,
$ sudo chmod 7777 /Users/{user}/library/caches/
递归更改权限,
$ sudo chmod 7777 -R /Users/{user}/library/caches/
或者您可以使用此命令拥有该目录,
$ sudo chown OWNER:GROUP /Users/{user}/library/caches/
其中 OWNER
是您计算机的用户名,您可以使用此命令在终端中找到它。
$ whoami
GROUP
是可选的。
大多数时候,sudo pip install
几乎不是您真正想要的。虽然在某些情况下,它可能“看起来”有效并解决了您眼前的问题。通常情况下,您只是在不知情的情况下破坏了系统 python。
在那个 repo 的上下文中,我会忽略 repo 的自述文件并执行此操作。
$ git clone https://github.com/ghimiredhikura/Eye-Color-Detection
$ cd Eye-Color-Detection
创建virtualenv环境,yourenvname
随便改
$ conda create -n yourenvname python=3.x
$ conda activate yourenvname
安装依赖项和运行代码
$ pip install -r requirements.txt
$ python3 eye-color.py --input_path=sample/2.jpg --input_type=ima
因为修复你的 conda 环境可能很难调试,这取决于你 sudo
在尝试解决你的问题时还有什么。如果您碰巧熟悉使用 python 的内置虚拟环境工具创建的“常规”virtualenv,那么您也可以尝试使用此工具。
$ python3 -m venv .venv --copies
$ source .venv/bin/active
$ pip install -r requirements.txt
$ python3 eye-color.py --input_path=sample/2.jpg --input_type=image