在Ubuntu上使用编译方式安装Python3.7

分类:随笔 日期:2020-08-18 作者:caocaofff 浏览:918

wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tar.xz
tar -xJf Python-3.7.7.tar.xz
cd Python-3.7.7
./configure
# 或者
#./configure --prefix=/usr/local/python3.7.7
make && make install

若执行的是 ./configure,则安装后可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/include,其它的资源文件放在/usr/local/share。

若执行的是./configure --prefix=/usr/local/python3.7.7,则可执行文件放在/usr/local/python3.7.7/bin,库文件放在/usr/local/python3.7.7/lib,配置文件放在/usr/local/python3.7.7/include,其它的资源文件放在/usr/local/python3.7.7/share

若执行./configure --prefix=/usr/local/python3.7.7,则需要添加环境变量。是./configure的跳过此步骤

#添加环境变量
PATH=$PATH:$HOME/bin:/usr/local/python3.7.7/bin

执行的是./configure,则:

mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/bin/pip3 /usr/bin/pip

执行的是./configure --prefix=/usr/local/python3.7.7,则:

mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3.7.7/bin/python3.7 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/python3.7.7/bin/pip3 /usr/bin/pip
CC版权: 本篇博文采用《CC 协议》,转载必须注明作者和本文链接

评论 (暂无评论)

发表评论

昵称:  
邮箱:  
网址: