1. 程式人生 > >centos6下安裝python3環境

centos6下安裝python3環境

ble 虛擬 efi rtu ria nbsp col vim comm

1. 下載python3.6

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

2. 解壓縮

tar -zxvf Python-3.6.4.tgz

mkdir -p /usr/local/python3

3. 安裝依賴

yum install openssl openssl-devel

yum install zlib zlib-devel

4.

vim Modules/Setup

#Socket module helper for socket(2)
_socket socketmodule.c timemodule.c

#Socket module helper 
for SSL support; you must comment out the other #socket line above, and possibly edit the SSL variable: SSL=/usr/local/ssl _ssl _ssl.c -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl -L$(SSL)/lib -lssl -lcrypto

5. 配置

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

6. 安裝

make && make install

7. 設置環境變量

cp /root/.bashrc /root/.bashrc.bak

echo ‘export PATH="$PATH:/usr/local/python/bin/">> /root/.bashrc

8. 創建虛擬環境

virtualenv -p /usr/local/python3/bin/python3.6 py36env //會在當前的路徑下生成一個py36env的文件夾

9. 激活虛擬環境

source /home/work/py36env/bin/activate

10. 退出虛擬環境

deactivate

centos6下安裝python3環境