ubuntu16安装python3
 2021-07-02 10:50:57   142   0   

本文最后更新于天前,文中介绍内容及环境可能已不适用.请谨慎参考.

虽然可以用各种PPA源安装,但是总是出现各种问题,还是老老实实源码安装配置!

python这玩意各种版本,每次都是烦的一米,这次是用ndoejs express感觉有点毛病,用python来验证下,

所有还得在新服务器上搞搞python环境。

 

话不多说,前置依赖:先装了再说。

sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

 

 

官网下载最新3.x源码

 

下载

解压.

tar zxvf Python-3.9.6.tgz Python-3.9.6/

建立本地安装目录

#建立目标安装位置
sudo mkdir -p /usr/local/python3.9

#下载解压目录
cd /usr/local/Python-3.9.6

#编译 安装
/usr/local/Python-3.9.6# ./configure --prefix=/usr/local/python3.9 --enable-optimizations
make && make install

耗时大好几分钟...

Processing /tmp/tmp5qmgrw1i/setuptools-56.0.0-py3-none-any.whl
Processing /tmp/tmp5qmgrw1i/pip-21.1.3-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.9 are installed in '/usr/local/python3.9/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.1.3 setuptools-56.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

 

直接干掉/usr/bin/下的python3,pip3

然后重新指向新安装目录

rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3

ln -s /usr/local/python3.9/bin/python3.9 /usr/bin/python3
ln -s /usr/local/python3.9/bin/pip3.9 /usr/bin/pip


root@cloud-qv94b8-2gzl:/usr/local/python3.9# python3 -V
Python 3.9.6
root@cloud-qv94b8-2gzl:/usr/local/python3.9# pip -V
pip 21.1.3 from /usr/local/python3.9/lib/python3.9/site-packages/pip (python 3.9)
root@cloud-qv94b8-2gzl:/usr/local/python3.9# 

 

 

lsb_release 问题

sudo cp  /usr/lib/python3/dist-packages/lsb_release.py /usr/local/python3.9/lib/python3.9/

 

venv问题

简直像捅了马蜂窝一样,∑( ° △ °|||)︴,以上仅供参考.

 


 2021-07-02 11:48:41 
 1

  本文基于CC BY-NC-ND 4.0 许可协议发布,作者:野生的喵喵 固定链接: 【ubuntu16安装python3】 转载请注明



发表新的评论
{{s_uid}}   , 欢迎回来.
您的称呼(*必填):
您的邮箱地址(*必填,您的邮箱地址不会公开,仅作为有回复后的消息通知手段):
您的站点地址(选填):
留言:

∑( ° △ °|||)︴

(๑•̀ㅂ•́)و✧
<( ̄) ̄)>
[]~( ̄▽ ̄)~*
( ̄ˇ ̄)
[]~( ̄▽ ̄)~*
( ̄ˇ ̄)
╮( ̄▽ ̄)╭
( ̄ε(# ̄)
(⊙ˍ⊙)
( ̄▽ ̄)~*
∑( ° △ °|||)︴

文章分类

可能喜欢 

KxのBook@Copyright 2017- All Rights Reserved
Designed and themed by 野生的喵喵   1623021   44955