Ubuntu安装Python指定版本及最新版pip

这里以python3.7.6为例

准备

  • 下载Python安装包:
wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz
  • 解压Python安装包
tar xzvf Python-3.7.6.tgz

开始安装

  1. cd到刚刚解压的Python路径中,然后运行 ./configure命令:

    cd Python-3.7.6
    ./configure
    
  2. 运行以下命令进行安装:

    make
    sudo make install
    
  3. 查看安装版本:

    python3 -V
    

安装最新版pip :

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py -i  https://mirrors.aliyun.com/pypi/simple/

查看安装版本:

pip -V
# 或者
pip3 -V

修改pypi镜像源

清华:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

安装第三方库时可能还需要:

sudo apt install python3-dev
发布了16 篇原创文章 · 获赞 17 · 访问量 2062

猜你喜欢

转载自blog.csdn.net/weixin_44129085/article/details/104793114