以下这段提醒我,根据错误信息显示,你在尝试升级 pip 和 setuptools 时遇到了权限问题。报错信息表明你没有足够的权限创建目录 /usr/local/lib/python3.6/site-packages/pip。
使用 --user 标志以用户身份运行命令:
pip3 install --upgrade --user pip setuptools
这将会将软件包安装到你的用户主目录下的 .local 目录中,而不是系统范围的位置。这样你就不需要超级用户权限来进行安装。
[david@localhost CTFd-master]$ pip3 install --upgrade pip setuptools
Cache entry deserialization failed, entry ignored
Collecting pip
Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
100% |████████████████████████████████| 1.7MB 844kB/s
Cache entry deserialization failed, entry ignored
Collecting setuptools
Downloading https://files.pythonhosted.org/packages/b0/3a/88b210db68e56854d0bcf4b38e165e03be377e13907746f825790f3df5bf/setuptools-59.6.0-py3-none-any.whl (952kB)
100% |████████████████████████████████| 962kB 1.4MB/s
Installing collected packages: pip, setuptools
Exception:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3.6/site-packages/pip/commands/install.py", line 365, in run
strip_file_prefix=options.strip_file_prefix,
File "/usr/lib/python3.6/site-packages/pip/req/req_set.py", line 789, in install
**kwargs
File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 854, in install
strip_file_prefix=strip_file_prefix
File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 1069, in move_wheel_files
strip_file_prefix=strip_file_prefix,
File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/usr/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib64/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/site-packages/pip'
在下段代码中,我们可以优先考虑pip3安装是需要添加“–user”
[david@localhost CTFd-master]$ pip3 install --user gevent
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Collecting gevent
Downloading gevent-22.10.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.8 MB)
|████████████████████████████████| 5.8 MB 4.1 MB/s
Requirement already satisfied: setuptools in /home/david/.local/lib/python3.6/site-packages (from gevent) (59.6.0)
Requirement already satisfied: zope.event in /home/david/.local/lib/python3.6/site-packages (from gevent) (4.6)
Requirement already satisfied: zope.interface in /home/david/.local/lib/python3.6/site-packages (from gevent) (5.5.2)
Collecting greenlet>=2.0.0
Downloading greenlet-2.0.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564 kB)
|████████████████████████████████| 564 kB 5.8 MB/s
Installing collected packages: greenlet, gevent
Successfully installed gevent-22.10.2 greenlet-2.0.2
另外如果出现以下错误说明需要安装编译器
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -c src/greenlet/greenlet.cpp -o build/temp.linux-x86_64-3.6/src/greenlet/greenlet.o
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
直接输入以下命令可以解决安装gevent的问题
sudo yum install gcc-c++