Python安装插件出现Can not execute setup.py since setuptools is not available的错误解决

Posted by Steven on 2022-03-26
Estimated Reading Time 2 Minutes
Words 395 In Total
Viewed Times

通常在安装依赖包的时候,会出现这种情况:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[root@scrna-web-01-0001 oe]# pip3 install mysqlclient==2.1.0
Collecting mysqlclient==2.1.0
Using cached mysqlclient-2.1.0.tar.gz (87 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
exit code: 1
╰─> [1 lines of output]
ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
[root@scrna-web-01-0001 oe]#

这种一般都是setuptools版本的问题,将setuptools的版本更新的最新:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@scrna-web-01-0001 oe]# pip3 install --upgrade setuptools
Requirement already satisfied: setuptools in /usr/local/python3/lib/python3.8/site-packages (41.2.0)
Collecting setuptools
Downloading setuptools-61.1.0-py3-none-any.whl (1.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 9.2 kB/s eta 0:00:00
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 41.2.0
Uninstalling setuptools-41.2.0:
Successfully uninstalled setuptools-41.2.0
Successfully installed setuptools-61.1.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv


再次尝试更新:

1
2
3
4
5
6
7
8
9
10
[root@scrna-web-01-0001 oe]# pip3 install mysqlclient==2.1.0
Collecting mysqlclient==2.1.0
Using cached mysqlclient-2.1.0.tar.gz (87 kB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-2.1.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@scrna-web-01-0001 oe]#

bingo~


如果您喜欢此博客或发现它对您有用,则欢迎对此发表评论。 也欢迎您共享此博客,以便更多人可以参与。 如果博客中使用的图像侵犯了您的版权,请与作者联系以将其删除。 谢谢 !