Python 3,Pip3和Sudo。 Sudo无法访问PIP安装的软件包

发布于 2025-01-23 00:03:46 字数 1004 浏览 0 评论 0原文

我试图弄清楚为什么我的sudo无法访问PIP安装的软件包。这是我以下设置的详细信息。

Ubuntu 20.04,新安装。带有Python3.8。 安装其他一些软件包,这些软件包安装了自己的Python(Intel MKL Oneapi),即Python3.9。此安装以某种方式使默认的python。我通过对python/python3和pip/pip3进行明确目标/usr/bin/python3(为3.8)来解决这个问题。

我做

pip安装包装

我使用python3启动Python

,它正确地定位了别名/usr/usr/bin/python3 导入包装没有问题。

在脚本中,我导入包装。如果我运行

python3设置。pyinstall

错误

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/test-    easy-install-8015.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python3.8/dist-packages/

遇到

会因拒绝许可而

: >没有名为包装的模块,

所以我很好奇,为什么sudo无法访问此软件包?

I'm trying to figure out why my sudo doesn't have access to pip installed packages. Here is the details of my setup below.

Ubuntu 20.04, Fresh install. Comes with Python3.8.
Install some other package, which installs its own Python (Intel MKL Oneapi), which is Python3.9. This install somehow makes that the default Python. I get around this by editting ~/.bashrc to explicitly target /usr/bin/python3 (which is 3.8) for python/python3 and pip/pip3 each.

I do

pip install packaging

I launch python with

python3 which correctly targets the alias'd /usr/bin/python3 and I am able to do import packaging without issue.

In a script, I import packaging. If I run

python3 setup.py install

I get an error with a permission denied :

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/test-    easy-install-8015.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python3.8/dist-packages/

`

So I then try

sudo python3 setup.py install

However I am now back to No module named packaging

SO I am curious, why does sudo not have access to this package?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文