前言:
此刻各位老铁们对“ubuntu装python36”大体比较着重,我们都需要知道一些“ubuntu装python36”的相关内容。那么小编同时在网摘上搜集了一些关于“ubuntu装python36””的相关资讯,希望同学们能喜欢,小伙伴们一起来学习一下吧!1.Ubuntu软件升级命令(按顺序执行)
sudo apt-get update
apt list --upgradable
sudo apt-get upgrade
sudo apt autoremove
我遇到的问题:
(1)sudo: vim: command not found
解决方法:
sudo apt-get install vim
(2)E: Failed to fetch Connection failed
解决方法:
vim /etc/resolv.conf
添加nameserver 8.8.8.8
2.在Ubuntu上安装Python3.7.4
ubuntu默认的python是
rookie@ubuntu:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
所以在终端输入了一下python3,发现是python3.5
rookie@ubuntu:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
版本都不是最新的,下面是安装最新版本的步骤:
(1)下载网址:在中选择自己需要的python源码包,我下载的是python3.7.4
rookie@ubuntu:~/Downloads$ wget
(2)解压Python-3.7.4.tgz
tar -zxvf Python-3.7.4.tgz
(3)建立一个空文件夹,用于存放python3程序
mkdir /home/rookie/Desktop/local/python3
(4)进入到刚才解压的Python3.7.4文件夹中,执行配置文件,编译,编译安装
cd Python-3.7.4
#./configure --prefix=/home/rookie/Desktop/local/python3(试验有问题)
./configure --prefix=/home/rookie/Desktop/local/python3 --enable-optimizations --with-ssl
make && make install
(5)执行make && make install结果报错了
zipimport.ZipImportError: can't decompress data; zlib not available
Makefile:1132: recipe for target 'install' failed
make: *** [install] Error 1
解决方法:
sudo apt install yum
sudo apt-get install net-tools
之后再make install还是报错
一般来说著名的linux系统基本上分两大类:
1 RedHat系列:Redhat、Centos、Fedora等
2 Debian系列:Debian、Ubuntu等
RedHat 系列:
1 常见的安装包格式 rpm 包,安装rpm包的命令是 “rpm -参数”
2 包管理工具 yum
3 支持tar包
Debian系列
1 常见的安装包格式 deb 包,安装deb包的命令是 “dpkg -参数”
2 包管理工具 apt-get
3 支持tar包
所以你Ubuntu不该用yum 该用apt-get
转载,文章原始出处:) 博客园:
su之后
apt-get install zlib*
然后再重新make && make install报错
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Makefile:1132: recipe for target 'install' failed
make: *** [install] Error 1
参考,执行
sudo apt-get install --reinstall zlibc zlib1g zlib1g-devsudo apt-get install libffi-dev libssl-dev libreadline-dev -y
(6)再次make && make install
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.0.3 setuptools-40.8.0
安装完成没有错误提示,成功安装
如果遇到下面的问题
ln: failed to create symbolic link '/usr/bin/python': File exists
说明已经有链接链到 /usr/bin/python上了,删除即可,使用命令
rm -rf /usr/bin/python
注意python后面不能加斜杠
(7)建立软连接
root@ubuntu:/home/rookie/Downloads/Python-3.7.4# ln -s /home/rookie/Desktop/local/python3/bin/python3.7 /usr/bin/python3.7
root@ubuntu:/home/rookie/Downloads/Python-3.7.4# ln -s /home/rookie/Desktop/local/python3/bin/pip3.7 /usr/bin/pip3
(8)输入Python3
root@ubuntu:/home/rookie/Downloads/Python-3.7.4# python3
Python 3.7.4 (default, Aug 6 2019, 16:57:38)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[5]+ Stopped python3
至此,Ubuntu的Python3已经更新到最新版本了。
标签: #ubuntu装python36