python setup.py install报错“error: can‘t create or remove files in install directory”

93 篇文章 4 订阅
27 篇文章 0 订阅

问题描述:

在服务器上配置安装pip时候缺少setuptools,安装setuptools报错:

$ python3 setup.py install
running install
/home/LIST_2080Ti/2080/setuptools-66.1.1/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/LIST_2080Ti/2080/setuptools-66.1.1/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
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/lib/python3.8/site-packages'

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

    /usr/lib/python3.8/site-packages/

This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).

  warnings.warn(
error: can't create or remove files in install directory

有的朋友使用

python setup.py install --user || exit 1

即可解决。

但是,我使用了之后报错

右下角报错且让我打开帮助:

Troubleshoot Visual Studio Code Integrated Terminal launch failures

 这位腾腾任天真CSDN博友分析如下

玩转ROS2的填坑之路-SetuptoolsDeprecationWarning: setup.py install is deprecated_腾腾任天真的博客-CSDN博客

简而言之就是setuptools版本太高,只有降档使用。

我是用的是setuptools-66.1.1,太高,考虑降低一下。

在服务器上使用60.0.1b版本,下载

wget https://files.pythonhosted.org/packages/6a/ee/0b2929a264a9a967d43321ca44c2ee27dfcc7c6b79a98d3f929433a97e62/setuptools-60.0.1.tar.gz

在服务器解压:

tar -xzvf setuptools-60.0.1.tar.gz 

切换到解压缩后的文件夹内:

cd setuptools-60.0.1

安装

python3 setup.py install

报错同上。

$ python3 setup.py install
running install
/home/LIST_2080Ti/2080/setuptools-60.0.1/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/LIST_2080Ti/2080/setuptools-60.0.1/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
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/lib/python3.8/site-packages'

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

    /usr/lib/python3.8/site-packages/

This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).

再换版本58.2.0报错:

:~/2080/setuptools-58.2.0$ python3 setup.py install
Traceback (most recent call last):
  File "setup.py", line 7, in <module>
    import setuptools
  File "/home/LIST_2080Ti/niejianhao/setuptools-58.2.0/setuptools/__init__.py", line 10, in <module>
    import distutils.core
ModuleNotFoundError: No module named 'distutils.core'

然后问题越来越多,我一度进入到崩溃的边缘。

但是这些问题归根结底是源于安装虚拟环境以运行程序,所以回到根子上发现,在sudo下的问题往往遇到权限问题。

退回时候发现,su会发生授权失败报错。

authorization failure

并且我也看到许多解决方案有sudo命令。

后来联系服务器分配的同学,果然是因为未把本用户加入到sudo files里面。正如当初的那个报错所说。

 xxx is not in the sudoers file. This incident will be reported.

然后让服务器分配者把用户加入到sudo file里就ok了。当权限不够的时候,越复杂的方法越没啥用。

本文前面的朋友不知道怎么避开这个权限问题的,但是很明显,我遇到的问题是权限不够导致的。

当学校或老师分配服务器权限时候不仅要有账户,密码,还要一些其它的代码操作权限,否则你基本没有安装依赖包的权利。

安装pip

python -m pip install --upgrade pip

结果,因为之前安装过重新写的时候显示已经安装过了。

LIST_2080Ti@ubuntu-SYS-7049GP-TRT:~/2080$ python -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /home/LIST_2080Ti/.local/lib/python3.8/site-packages (22.3.1)

下面展示一下加过权限后的顺滑命令操作。

这就安装上了pip3和虚拟环境. 

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ACMSunny

赠人玫瑰,手有余香。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值