RHEL7.3 install python3.6.1 steps
1. download Python-3.6.1.tgz
2. tar -zxvf Python-3.6.1.tgz
3. yum install gcc openssl-devel python-devel openldap-devel sqlite-devel zlib-devel bzip2-devel ncurses-devel readline-devel tk-devel gdbm-devel xz-devel
4. cd Python-3.6.1
5. ./configure&make&make install
6. python3 --version
7. pip3 --version
如果在使用pip3安装其他python库时报错,一般是系统缺少相应的rpm包导致。
解决方法:
1. yum install 缺失的rpm包
2. 进入Python-3.6.1源码包目录,重新make&make install
3. 再次使用pip3安装
Python3常用第三方库:
pip3 install pymysql (yum install mysql*)
pip3 install python-ldap (yum install openldap-devel)
如果pip3使用常见问题
问题1:
[wiseo@cmdb-srv02 ~]$ pip3 list
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip import main
ImportError: cannot import name 'main'
解决办法:
[root@cmdb-srv02 ~]# easy_install-3.6 -U pip
问题2:
[wiseo@cmdb-srv02 ~]$ pip3 list
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
ImportError: cannot import name 'load_entry_point'
解决办法:
[root@cmdb-srv02 ~]# chmod -R a+rX /usr/local/lib/python3.6/site-packages/