pip/python:普通站点包不可写 [英] pip/python: normal site-packages is not writeable

查看:71
本文介绍了pip/python:普通站点包不可写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台新 Macbook - 一个用户安装了它,然后我安装了一个新用户(我的),授予管理员权限并删除了旧用户.我使用的是 OS Catalina.

I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.

自从安装以来,我一直有几个权限问题.VSCode 找不到 Jupyter Notebook,pip~/Library/Python/3.7/site-packages 安装包.

Since the installation I've been having several permission problems. VSCode can't find Jupyter Notebook, pip installs packages at ~/Library/Python/3.7/site-packages.

当我执行 which python3 时,我得到 usr/bin/python3.当我执行 pip3 install <package> 我得到: 默认为用户安装,因为普通的站点包不可写 然后它说它已经安装,即使我在执行 import 时无法访问它.

When I do which python3 I get usr/bin/python3. When I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.

很明显这是一个权限问题,pip 无法安装到base"python,他们python找不到我在~/Library/Python/3.7/site-packages中安装的东西.

It's seems clear that this is a permission problem, pip can't install to the "base" python, and them python can't find what I've installed into ~/Library/Python/3.7/site-packages.

我试过重新安装操作系统,但由于我没有进行全新安装,所以它没有改变任何东西.我错过了什么?我究竟该如何修复权限?我想要包安装在哪里(venv当然,但我想要一些全局包(比如jupyter).

I've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything. What am I missing? How exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).

推荐答案

正如@TomdeGeus 在评论中提到的,这个命令对我有用:

As @TomdeGeus mentioned in the comments, this command works for me:

Python 3:

python3 -m pip install [package_name]

Python 2:

python -m pip install [package_name]

这篇关于pip/python:普通站点包不可写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆