概述
1. 安装依赖环境
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2. 下载Python3
https://www.python.org/downloads/
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
# wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
3. tar -zxvf Python-3.6.1.tgz
4. 进入解压后的目录,编译安装。
# cd Python-3.6.1
# ./configure --prefix=/usr/local/python3
# make && make altinstall
5. 建立python3的软链
# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
6. 并将/usr/local/python3/bin加入PATH
(有些服务器不需要加入 可能已经加入可 Python3 看看)
# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
按ESC,输入:wq回车退出。
7. 修改完记得执行行下面的命令,让上一步的修改生效:
# source ~/.bash_profile
8. 检查Python3及pip3是否正常可用:
# python3 -V
Python 3.6.1
# pip3 -V
(1) -bash: pip3: command not found 不可用
(2) pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6) 可用
7.不行的话在创建一下pip3的软链接(我也不清楚这一步有什么用)
# ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3
[root@iZ2ze2gicjp6mmu1g4beekZ ~]# pip3 -V
-bash: pip3: command not found
[root@iZ2ze2gicjp6mmu1g4beekZ ~]# pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.1)
setuptools (28.8.0)
最后
以上就是烂漫洋葱为你收集整理的Linux安装Python3.6的全部内容,希望文章能够帮你解决Linux安装Python3.6所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复