[教程]在宝塔面板python2的基础上安装python3
1月22日更新• Python3 • 宝塔•教程•阅读:3,456次
宝塔面板默认是装的python2,好多朋友需要安装python3,但安装python3 之后运行不了宝塔面板。下面我来介绍怎样同时安装python3和python2。
1.下载python3安装包并解压
- wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
- tar –xzvf Python–3.6.0.tgz
2、进入解压,编译安装包,指定安装路径,并执行安装命令
- cd Python–3.6.0
- ./configure –prefix=/usr/local/python36 #注意:prefix参数用于指定将Python安装在新目录,防止覆盖系统默认安装的python
- make && make install
3.建立软链接(python3的环境变量)
- ln –s /usr/local/python36/bin/python3.6 /usr/bin/python3 ####如果提示软连接已经存在,那么先用下面的,断开原先的软连接
- rm -rf /usr/bin/python3
- ln –s /usr/local/python36/bin/python3.6 /usr/bin/python3 ###再次运行,即可
4、完成
- [root@Rserver–1 Python–3.6.0]# python3
- Python 3.6.0 (default, May 25 2017, 11:39:00)
- [GCC 4.4.7 20120313 (Red Hat 4.4.7–18)] on linux
- Type “help”, “copyright”, “credits” or “license” for more information.
- >>>
- >>>