Ubuntu 安装 python3.7.4详细指南

目录

1. 安装python3的依赖

2. 下载python3的包

3. 编译python3.7

  4. 检验是否安装成功

  5. 安装python3.7出现ModuleNotFoundError: No module named ‘_ctypes’解决办法


linux安装python3.7分三步

  • 1. 安装python3的依赖
  • 2.下载python3的包
  • 3.编译与安装python

请参照下面步骤,按顺序来。

1. 安装python3的依赖

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
    libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

2. 下载python3的包

网页下载

https://www.python.org/ftp/python/

https://www.python.org/downloads/

命令下载:

sudo wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz  # 下载python3.7.4的包

推荐解压后放在 /usr/loacl/python3 的目录下

下面是命令参考:

sudo su # 切到管理员
cd /usr/loacl # 进入指定目录
mkdir python3 # 创建python3的目录
cd python3 # 进入python3的目录
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz # 下载python3.7.4的包
tar xzf Python-3.7.4.tgz # 解压包

3. 编译python3.7

进入Python-3.7.4解压的目录

cd Python-3.7.4
sudo ./configure --enable-optimizations 或 ./configure --prefix=/usr/local/python3 --with-ssl
sudo make altinstall 或 make && make install

make altinstall用于防止替换默认的python二进制文件/usr/bin/python

4. 检验是否安装成功

python3 -V

看到python版本号对不对,如果为3.7说明安装成功

5. 安装python3.7出现ModuleNotFoundError: No module named ‘_ctypes’解决办法

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev

参考:https://www.cnblogs.com/fan-gx/p/11137910.html

你可能感兴趣的:(python)