(一)Linux中安裝python3html
一、首先安裝依賴包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-develpython
依次執行以下命令sql
二、下載python的安裝包centos
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4rc1.tgzbash
三、解壓安裝app
tar -xvf Python-3.6.4rc1.tgz ide
cd Python-3.6.4rc1/測試
./configure --prefix=/usr/local/python3centos7
make.net
make install
四、創建軟連接
cd /usr/bin
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
五、更新pip
pip3 install --upgrade pip
參考:
http://www.javashuo.com/article/p-netwgerj-cy.html
(二)【python3安裝虛擬環境】
一、安裝虛擬環境python包
安裝虛擬環境的命令:
1)sudo pip3 install virtualenv #安裝虛擬環境
2)sudo pip3 install virtualenvwrapper #安裝虛擬環境擴展包
3)編輯家目錄下面的.bashrc文件,添加下面幾行。(設置python的新環境變量)
# python3
WORKON_HOME=$HOME/.virtualenvs
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/python3/bin/virtualenv
source /usr/local/python3/bin/virtualenvwrapper.sh
4)使用source .bashrc使其生效一下。
5)若是報錯:
virtualenvwrapper.sh: There was a problem running the initialization hooks.
就修改virtualenvwrapper.sh的which python 爲which python3
6)測試虛擬環境
mkvirtualenv test01
二、新建虛擬環境統一目錄
mkdir /home/venvs
cd /home/venvs
三、新建名爲siew_py3的虛擬環境
cd /home/venvs
virtualenv siew_py3
ll
四、激活siew_py3的虛擬環監局
chmod +r /home/venvs/siew_py3/bin/activate
source /home/venvs/siew_py3/bin/activate
或者
. /home/venvs/siew_py3/bin/activate
五、退出虛擬環境
deactivate
注意:
其餘文章:centos7中安裝python3
http://blog.csdn.net/wjqwinn/article/details/75633714
一、安裝gcc前的準備
yum provides '*/applydeltarpm'
yum install deltarpm -y
二、安裝升級相應的依賴包(含gcc)yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make