How to install Python in Ubuntu 在Ubuntu编译安装Python

2021年5月27日 1711点热度 0人点赞 0条评论

How to install Python in Ubuntu

This is an old school topic. You may be professional in Python, Java, C++, and Rust. You may use conda in your research. But what about commercial use? Conda is not free. Sometimes you need a pure Python environment, especially when you are using Docker to build an image.


假设你已经是root user. 首先,安装必要的依赖

apt-get update && apt-get upgrade -y &&\
    apt-get install -y wget \
    build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev

下载并编译Python 3.8.0

wget &&\
    tar -xf Python-3.8.0.tgz &&\
    cd Python-3.8.0 &&\
    ./configure --enable-optimizations &&\
    make -j8 &&\
    make altinstall


update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.8 3 &&\
    update-alternatives --install /usr/bin/pip3 pip3 /usr/local/bin/pip3.8 3 &&\
    pip3 install --upgrade pip

Dong Wang

I will work as a PhD student of TU Graz in Austria. My research interests include Embedded/Edge AI, federated learning, computer vision, and IoT.