redhat安裝python3.7

下載並解壓:python

1 wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
2 tar -xzvf Python-3.7.2.tgz

進入目錄:mysql

cd Python-3.7.2

編譯:
linux

./configure --prefix=/usr/local/python3

 

安裝:sql

make
make insatllbash

缺乏依賴包致使:ide

執行:yum -y install zlib*  安裝依賴包便可測試

仍缺乏組件,沒法導入_ctypes模塊:ui

1 yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2 yum install libffi-devel -y

https://cpython-devguide.readthedocs.io/setup/#build-dependencies
注意:此步驟安裝完成以後,須要從新編譯文件
spa

 

安裝完成以後,python已經安裝成功,可是須要配置環境變量,(若是不想配置環境變量能夠在編譯那一步將  --prefix=/usr/local/python3 這一部分去掉【沒有測試】code

建立軟鏈接便可,

1 [root@bing ~]# mv /usr/bin/python /usr/bin/python_bak
2 [root@bing ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
3 [root@bing ~]# python
4 Python 3.7.2 (default, Feb 23 2019, 19:05:50) 
5 [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
6 Type "help", "copyright", "credits" or "license" for more information.
7 >>> exit()

 

 pip還沒法使用

1 [root@bing ~]# PATH=$PATH:$HOME/bin:
2 [root@bing ~]# PATH=$PATH:$HOME/bin:/usr/local/python3/bin

配置完環境變量(在本次會話中)便可使用pip,最好是建立軟鏈接

續;

安裝過程當中出現:pip is configured with locations that require TLS/SSL, however the ssl modul

#從新編譯安裝 ./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl make make install #從新第三方庫pymysql pip3 intall pymysql
相關文章
相關標籤/搜索