DEV Community

Chenglu
Chenglu

Posted on

1

Installing Python 3.7.4 from source

I keep installing the Python from source, for two reason:

  1. More flexibility to manage. Cause I decide where to install it, which python module to enable.
  2. Chose the latest version. Python comes from system package manager is sometimes a older version.

Download Python source code.

wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
mkdir ~/.python3
mv Python-3.7.4.tgz ~/.python3
cd ~/.python3
tar -zxvf Python-3.7.4.tgz

Install dependencies

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev

Enable ssl module

vim ~/.python3/Python-3.7.4/Modules/Setup.dist

find keyword ssl and uncomment this lines:

# SSL=/usr/local/ssl
# _ssl _ssl.c \
#         -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
#         -L$(SSL)/lib -lssl -lcrypto

Compile and install

./configure --prefix=/root/.python3/ --with-ensurepip
make
make install

Add bin to PATH

Now the python3 and pip binary are located at ~/.python3/bin, you can add the directory to $PATH to access those commands directly.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay