1.安裝Python3.6
安裝准備
mkdir /usr/local/python3 wget --no-check-certificate https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz tar -xzvf Python-3.6.0.tgz cd Python-3.6.0
編譯安裝
./configure --prefix=/usr/local/python3
make && make install
將默認Python修改為Python3.6,並為其創建軟連接
mv /usr/bin/python /usr/bin/python.bak ln -s /usr/local/python3/bin/python3 /usr/bin/python
修改yum使用的原python的配置文件
vim /usr/bin/yum
#!/usr/bin/python --> #!/usr/bin/python2.7 vim /usr/libexec/urlgrabber-ext-down #!/usr/bin/python --> #!/usr/bin/python2.7
2.安裝pip3
安裝pip依賴庫
yum -y install zlib zlib-devel
如果安裝上述依賴庫出現以下報錯:Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
請執行以下操作:yum provides '*/applydeltarpm'
,出現上述問題的原因是缺少增量RPM條件,需要使用上述命令插敘具體缺少的套件名稱,並進行安裝。
安裝setuptools
Python的包管理工具,安裝其他模塊依賴此模塊支持。
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26 tar -zxvf setuptools-19.6.tar.gz cd setuptools-19.6 python3 setup.py build python3 setup.py install
如果提示:zlib需要安裝zlib-devel,並重新編譯安裝Python3.6
安裝pip,並為其創建軟連接
wget --no-check-certificate https://github.com/pypa/pip/archive/9.0.1.tar.gz tar -zvxf 9.0.1 -C pip-9.0.1 cd pip-9.0.1 python3 setup.py install ln -s /usr/local/python3/bin/pip /usr/bin/pip3
升級pip
pip3 install --upgrade pip
pip3 install ipython
ln -s /usr/local/python3/bin/ipython /usr/bin/ipython3
cmd
python
pip install pygame
python -m pygame.examples.aliens
pycharm 導入pygame
https://www.cnblogs.com/LHJL8023/p/8441016.html