Linux(CentOS7)上面安裝Python3
安裝Python3
環(huán)境
安裝CentOS 7.2最小系統(tǒng)(CentOS-7-x86_64-Minimal-1511.iso)
需求
- Python-3.6.4.tar.xz(官網(wǎng)下載)
- GCC(yum安裝)
- 一堆開發(fā)庫(kù)(yum安裝)
編譯
- 安裝編譯器
yum -y install gcc
- 安裝依賴
yum -y install bzip2-devel sqlite-devel openssl-devel readline-devel xz-devel xz-devel tk-devel gdbm-devel
- 編譯源碼
tar -zxvf Python-3.6.4.tar.xz
cd Python-3.6.4
./configure
(如果需要發(fā)布版瓮增,則配置時(shí)要開優(yōu)化梭姓,編譯較慢./configure --enable-optimizations)
make -j4
make install
默認(rèn)安裝到/usr/local
注意如果不安裝3.2依賴開發(fā)庫(kù),則編譯完成后會(huì)提示有些模塊沒(méi)有編譯
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2 _curses _curses_panel
_dbm _gdbm _lzma
_sqlite3 _ssl _tkinter
readline zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
atexit pwd time
running build_scripts
運(yùn)行
[root@py3 Python-3.6.4]# python3
Python 3.6.4 (default, Jan 16 2018, 10:17:58)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Ubantu 上面安裝Python3嘉熊、Scrapy
sudo apt-get install build-essential python3-dev libssl-dev libffi-dev libxml2 libxml2-dev libxsltl-dev zliblg-dev