python模块安装权限问题(error: can't create or remove files in install directory)

本文介绍了在使用Python安装第三方模块时遇到的权限问题及解决方案。当尝试使用python setup.py install命令安装setuptools等模块时,可能会遇到无法在安装目录创建或删除文件的错误。文章提供了一个简单的解决方法,即在Linux环境下使用sudo python setup.py install命令来获取足够的权限完成安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    一开始装好python,,我们手动给它配置环境安装模块会出现一些问题。比如“python setup.py install”,当我们安装setuptools时可能会出现错误提示“error: can't create or remove files in install directory”,由于权限问题我们不能在某些文件夹写入文件,那么解决办法如下:

    "sudo python setup.py install",注意sudo是Linux系统下的命令,Windows下不可用, 了解一下!

ma@ubuntu:~/Downloads/torchvision$ python3 setup.py install setup.py:10: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import DistributionNotFound, get_distribution, parse_version Building wheel torchvision-0.15.1 Compiling extensions with following flags: FORCE_CUDA: False DEBUG: False TORCHVISION_USE_PNG: True TORCHVISION_USE_JPEG: True TORCHVISION_USE_NVJPEG: True TORCHVISION_USE_FFMPEG: True TORCHVISION_USE_VIDEO_CODEC: True NVCC_FLAGS: Found PNG library Building torchvision with PNG image support libpng version: 1.6.37 libpng include path: /usr/include/libpng16 Running build on conda-build: False Running build on conda: False Building torchvision with JPEG image support Building torchvision without NVJPEG image support ffmpeg: symbol lookup error: ffmpeg: undefined symbol: avio_protocol_get_class, version LIBAVFORMAT_58 Building torchvision without ffmpeg support Error fetching ffmpeg version, ignoring ffmpeg. Building torchvision without ffmpeg support Building torchvision without video codec support running install /home/ma/.local/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** !! self.initialize_options() /home/ma/.local/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` and ``easy_install``. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://github.com/pypa/setuptools/issues/917 for details. ******************************************************************************** !! self.initialize_options() 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).
06-04
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值