Centos8 上安装gevent遇到的一些问题
1、在编写协程相关的代码时,发现系统没有安装gevent
这个包,于是尝试使用pycharm上的懒人工具去安装gevent包,但是一直出错,放弃打算使用pip来安装
2、使用pip
[fancy@localhost ~]$ pip
bash: pip: command not found...
[fancy@localhost ~]$ su root
Password:
[root@localhost fancy]# pip
bash: pip: command not found...
[root@localhost fancy]# yum install pip
Last metadata expiration check: 2:10:06 ago on Thu 05 Nov 2020 04:51:32 PM CST.
No match for argument: pip
Error: Unable to find a match: pip
[root@localhost fancy]# whereis python
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python2.7 /usr/lib/python3.6 /usr/lib/python2.7 /usr/lib64/python3.6 /usr/lib64/python2.7 /usr/include/python3.6m /usr/include/python2.7 /usr/share/man/man1/python.1.gz
[root@localhost fancy]# whereis python3
python3: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3 /usr/lib/python3.6 /usr/lib64/python3.6 /usr/include/python3.6m /usr/share/man/man1/python3.1.gz
有点震惊,调不出来,安装也不行,神魔鬼?
后来查博客,找到一篇关于安装pip的博客:链接: CentOS安装python3及pip3.
发现安装了python3的机器上是已经有pip的了,试下:
[fancy@localhost bin]$ cd /bin
[fancy@localhost bin]$ ls | grep pip
lesspipe.sh
pip-2
pip2
pip-2.7
pip2.7
pip-3
pip3
pip-3.6
pip3.6
pipewire
[fancy@localhost bin]$
的确如此,于是可以愉快的使用pip工具了
3、然后,输入命令:pip3 install gevent
[root@localhost fancy]# pip3.6 install gevent
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3.6 install --user` instead.
Collecting gevent
Downloading https://files.pythonhosted.org/packages/78/c4/0c59bf329240981fd3a228ac809a82d00d4b147a82555eb4dddba2d041aa/gevent-20.9.0.tar.gz (5.8MB)
100% |████████████████████████████████| 5.8MB 77kB/s
Collecting zope.event (from gevent)
Downloading https://files.pythonhosted.org/packages/9e/85/b45408c64f3b888976f1d5b37eed8d746b8d5729a66a49ec846fda27d371/zope.event-4.5.0-py2.py3-none-any.whl
Collecting zope.interface (from gevent)
------------------------------------此处省略N万字--------------------------------------------
src/gevent/libev/corecext.c:95:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sls51kqw/gevent/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-dky2nqj0-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-sls51kqw/gevent/
[root@localhost fancy]
出现了这个错误:fatal error: Python.h: No such file or directory
网上查了N篇博客,总结以下就是:没有安装python 的dev包
那就安装
[root@localhost fancy]# yum install python3-devel
Last metadata expiration check: 2:36:58 ago on Thu 05 Nov 2020 04:51:32 PM CST.
Dependencies resolved.
=======================================================================================================================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================================================================================================================
Installing:
python36-devel x86_64 3.6.8-2.module_el8.1.0+245+c39af44f AppStream 16 k
Installing dependencies:
platform-python-devel x86_64 3.6.8-23.el8 AppStream 246 k
python-rpm-macros noarch 3-38.el8 AppStream 14 k
python-srpm-macros noarch 3-38.el8 AppStream 14 k
python3-rpm-generators noarch 5-6.el8 AppStream 24 k
python3-rpm-macros noarch 3-38.el8 AppStream 13 k
Transaction Summary
=======================================================================================================================================================================================================================================
Install 6 Packages
安装过程全选y
就行,开发包安装完成。
4、安装gevent
[root@localhost fancy]# pip3.6 install gevent
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3.6 install --user` instead.
Collecting gevent
Using cached https://files.pythonhosted.org/packages/78/c4/0c59bf329240981fd3a228ac809a82d00d4b147a82555eb4dddba2d041aa/gevent-20.9.0.tar.gz
Requirement already satisfied: zope.event in /usr/local/lib/python3.6/site-packages (from gevent)
Requirement already satisfied: zope.interface in /usr/local/lib64/python3.6/site-packages (from gevent)
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from gevent)
Requirement already satisfied: greenlet>=0.4.17 in /usr/local/lib64/python3.6/site-packages (from gevent)
Installing collected packages: gevent
Running setup.py install for gevent ... done
Successfully installed gevent-20.9.0
[root@localhost fancy]#
搞定!