安裝Python3
Notes:操作系統:CentOS7
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
tar -xvf Python-3.6.3.tar.xz
cd Python-3.6.3
./configure
make && make install
然而,報錯了!!
各種報錯
- zipimport. ZipImportError: can’t decompress data; zlib not available
Solution: 缺少包,下載安裝
yum install zli*
- Error: Multilib version problems found.
Solution: 發現了多個版本,忽略
yum install -y zlib zlib-devel --setopt=protected_multilib=false
cd Python-3.6.3
./configure
make && make install
成功:
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
將原來 python 的軟鏈接重命名:
mv /usr/bin/python /usr/bin/python.bak
將 python 鏈接至 python3:
ln -s /usr/local/bin/python3 /usr/bin/python
- pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
該錯誤在執行 pip install django
時出現。
Solution: 不支持 SSL,安裝 openssl-devel
yum install openssl-devel
裝完後,重新編譯安裝Python
cd Python-3.6.3
./configure --with-ssl
make && make install
- File “/usr/bin/yum”, line 30 except KeyboardInterrupt, e:
該錯誤在執行 yum install openssl-devel
時出現。
cd /usr/bin/
ls -l python*
Solution: yum安裝軟件時,需要Python的支持,默認爲Python2
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
將#! /usr/bin/python 改爲 #! /usr/bin/python2
- Found 1 pre-existing rpmdb problem(s), ‘yum check’ output follows:zlib-1.2.7-18.el7.x86_64 is a duplicate with zlib-1.2.7-13.el7.i686
該錯誤在執行 yum install mysql-devel gcc gcc-devel python-devel --skip-broken
時出現。
Solution: 版本衝突,列出所有的版本,移除沒用的版本
rpm -qa | grep zlib
zlib-1.2.7-18.el7.x86_64
zlib-devel-1.2.7-18.el7.x86_64
zlib-1.2.7-13.el7.i686
yum remove zlib-1.2.7-13.el7.i686
- OSError: mysql_config not found
該錯誤在執行 pip install mysqlclient
時出現。
Solution: 主要是倉庫裏沒有mysql的源。。先移除,再安裝
yum -y remove mysql57-community-release-el7-7.noarch
[root@rabbitmq yum.repos.d]# cd /etc/yum.repos.d/
[root@rabbitmq yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo
CentOS-Base.repo.rpmnew CentOS-Epel.repo CentOS-Sources.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Vault.repo
[root@rabbitmq yum.repos.d]# rpm -ivh http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm
Retrieving http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm
Preparing...################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-7 ################################# [100%]
[root@rabbitmq yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo mysql-community.repo
CentOS-Base.repo.rpmnew CentOS-Epel.repo CentOS-Sources.repo mysql-community-source.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Vault.repo
終於沒有錯誤了,啓動。。
pip install mysqlclient
python manage.py runserver
If you have any questions or any bugs are found, please feel free to contact me.
Your comments and suggestions are welcome!