python - Anaconda Sudo PIP 权限问题
问题描述
我正在学习 Python 并安装了 Anaconda,我正在尝试让自己熟悉让Eye-Color Detection 项目正常工作的过程。阅读自述文件后,我遇到了以下错误:
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 环境中正确执行此操作?
解决方案
大多数时候,asudo pip install
几乎从来都不是你真正想要的。虽然在某些情况下,它可能会“看起来”起作用并解决您的直接问题。通常,您只是在不知情的情况下破坏了系统 python。
在那个 repo 的上下文中,我会忽略 repo 的 README 并这样做。
$ 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
推荐阅读
- laravel - 如何在没有 php 序列化的情况下使用 laravel 将原始 json 字符串存储在 redis 缓存中?
- node.js - 无法在 worker_threads 中调用类实例方法
- angular - 为什么提供者在组件中不起作用?
- android - 如何解决 Android Studio 4.1 中与 com.google.android.material 资源 ID 相关的“无法解析符号 'R'”?
- python - 在python中以10秒的间隔打印当前时间10次
- asp.net-core - Razor Pages 在页面加载时设置当前日期
- python - 将 SQL 查询的转换从 '::' 重构为整个代码库上的 CAST
- html - 使用 Tampermonkey/Userscript 组织 UL List
- docker - 使用卷挂载将文件从容器复制到本地
- docusaurus - 导入外部 React 组件的捷径是什么?