CentOS 6.8 安装 python3 和 pip3

$ sudo apt-get install python34
$ python3 --version
$ 
$ wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py
$ pip3 -v

源代码安装

去这里下载源代码:https://www.python.org/downloads/source/

$ wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
$ tar xf Python-3.6.4.tar.xz
$ cd Python3.6.4
$ ./configure --enable-optimizations
$ make
$ sudo make install

常见错误

错误一:https无法访问

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping

原因是在make时,系统没有安装openssl-devel

$ sudo yum install openssl-devel
$ ./configure --enable-optimizations
$ make
$ sudo make install

错误二:zlib相关

zipimport.ZipImportError: can't decompress data; zlib not available

原因:在make时,系统没有安装zlib-devel

$ sudo yum install zlib-devel
$ ./configure --enable-optimizations
$ make
$ sudo make install

results matching ""

    No results matching ""