我是靠谱客的博主 烂漫洋葱,这篇文章主要介绍Linux安装Python3.6,现在分享给大家,希望可以做个参考。

1. 安装依赖环境

复制代码
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/

复制代码
1
2
3
# 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. 进入解压后的目录,编译安装。

复制代码
1
2
3
4
# cd Python-3.6.1 # ./configure --prefix=/usr/local/python3 # make && make altinstall

5. 建立python3的软链

复制代码
1
# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3

6. 并将/usr/local/python3/bin加入PATH

(有些服务器不需要加入 可能已经加入可 Python3 看看)

复制代码
1
2
3
4
5
6
7
8
9
# 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. 修改完记得执行行下面的命令,让上一步的修改生效:

复制代码
1
# source ~/.bash_profile

8. 检查Python3及pip3是否正常可用:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部