安裝python
1.安裝環境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-develreadline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel sqlite-devel
2.下載包
wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tgz
3.解壓包
tar -zxvf Python-3.7.7.tgz
4.創建安裝目錄,進入解壓后的包,制定安裝路徑進行安裝
mkdir -p /usr/local/python3 cd Python-3.6.1 ./configure --prefix=/usr/local/python3
報錯: [root@localhost Python-3.7.7]# ./configure --prefix=/usr/local/python3 checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for python3.7... no checking for python3... no checking for python... python checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... checking for --without-gcc... no checking for --with-icc... no checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/root/Python-3.7.7': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
因為缺少GCC編譯環境:
yum -y install gcc
5.編譯安裝
make && make install
6.創建軟連接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
7、在線升級pip和setuptools
./pip3 install --upgrade setuptools pip
python默認的pip版本和setuptools版本比較舊,如果有網,可以在線更新,下面記錄一下離線更新
8.
第7步的升級不成功
手動安裝,官網查的安裝方法
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
然后到下載目錄執行以下命令:
python get-pip.py
9.升級Pip
[root@localhost bin]# pip3 install -U pip Requirement already up-to-date: pip in /usr/local/python3/lib/python3.7/site-packages (20.0.2) [root@localhost bin]# which pip3 /usr/bin/pip3