安装步骤:
1.下载Python-3.5.4.tgz安装压缩包(可到python官网下载)
2. mkdir /usr/local/python3
3. tar -zxvf Python-3.5.4.tgz(解压到/usr.local/python3)
4. yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel (安装特定的开发程序)
5. cd /usr/local/python3/Python-3.5.4(cd到解压出来的目录上)
6 ./configure --prefix=/usr/local/python3.5(在/usr/localpython3/Python-3.5.4/路径安装)
7. make && make install
问题1: Python3.5安装报错 configure: error: in `/usr/local/python3/Python-3.5.4':
报错描述:
[root@localhost Python-3.5.4]# ./configure --prefix=/usr/local/python3.5
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.5... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
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 `/usr/local/python3/Python-3.5.4':
configure: error: no acceptable C compiler found in $PATH
问题分析:缺少gcc编译环境
解决方法:
yum -y install gcc
问题2: 安装python时出现Ignoring ensurepip failure:pip required SSL/TLS
报错描述:
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS
问题分析:缺少openssl-devel包
解决方法:
yum -y install openssl-devel
问题3:如何设置环境变量,直接输入python3就可以进入python3版本
解决方法:
echo "export PATH=$PATH:/usr/local/python3/bin/" >> /etc/profile.d/python3.sh
export PATH=$PATH:/usr/local/python3/bin/
问题4:如果装了ipython,如何在python2,python3都可以使用ipyhon
解决方法:
先使用pip2 -V 和 pip3 -V 确认对应的python版本正确
之后
pip2 install ipython 安装python2的
pip3 install ipython 安装python3的
最后shell中执行ipython或ipython3会进入不同的python版本