概述
荐:一行命令搞定(仅适用通过apt或yum来安装包的系统[ubuntu/red hat/centos])
curl https://bc.gongxinke.cn/downloads/install-python-3.7.0 | bash
--------------------------------------------------------------------
平常是这么安装的...
方法一:从python官网下载安装包来安装,适合网速好的情况
-
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz &&
-
tar -xvf Python-3.7.0.tar.xz &&
-
cd Python-3.7.0 &&
-
./configure && make && sudo make altinstall
--------------------
如果报这个错误:
ModuleNotFoundError: No module named '_ctypes'
可通过安装libffi(-dev[el])
https://bugs.python.org/issue31652
来解决(安装完重新运行sudo make altinstall),Ubuntu用这个命令:
sudo apt install libffi-dev
centos是这个:
sudo yum install libffi-devel
更周全的方法是不单安装libffi(-dev[el])
还安装其他python开发所需的包(Ubuntu):
-
sudo apt update -y
-
sudo apt install -y build-essential libncursesw5-dev libgdbm-dev libc6-dev zlib1g zlib1g-dev libsqlite3-dev tk-dev libssl-dev openssl libffi-dev python3-dev python3-smbus
centos:
-
sudo yum update -y
-
sudo yum groupinstall -y "development tools"
-
sudo yum install zlib zlib-devel bzip2-devel openssl openssl-devel libffi-devel ncurses-devel xz-devel python3-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel expat-devel
方法二:从国内的网站下载安装包,适合访问python官网比较慢或访问不到的情况:
-
wget https://bc.gongxinke.cn/downloads/Python-3.7.0.tar.xz &&
-
tar -xvf Python-3.7.0.tar.xz &&
-
cd Python-3.7.0 &&
-
./configure && make && sudo make altinstall
或:
curl https://bc.gongxinke.cn/downloads/install-python-3.7.0 | bash
附:
安装python3.6.6:
curl https://bc.gongxinke.cn/downloads/install-python-3.6.6 | bash
md5校验(https://www.python.org/downloads/release/python-370/):
echo 'eb8c2a6b1447d50813c02714af4681f3 md5-from-python.org' && md5sum Python-3.7.0.tar.xz
----------------------------------
安装过程如果遇到这个错误:
zipimport.ZipImportError: can't decompress data; zlib not available
编辑文件 Python-3.7.0/Modules/Setup
查找zlib,去掉第338行zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz前面的#,保存
然后重新运行:
cd Python-3.7.0 && make && sudo make altinstall
------------------------------------------------
如果遇到了./Modules/zlibmodule.c:10:10: fatal error: zlib.h: No such file or directory
ubuntu中通过安装这个解决了(安装后需要重新make和make altinstall):
sudo apt-get install zlib1g-dev
最后
以上就是阳光电话为你收集整理的linux 一行命令安装python3.7的全部内容,希望文章能够帮你解决linux 一行命令安装python3.7所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复