May 5, 2021


linux python asdf

Problem - unhappy Python

I was setting up a new Ubuntu machine today and was using asdf to get me there. asdf install python 3.9.5 complained that various dependencies for Python extensions like bz2 and OpenSSL were missing.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ sudu install python 3.9.5
python-build 3.9.5 /home/dylan/.asdf/installs/python/3.9.5
Downloading Python-3.9.5.tar.xz...
-> https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tar.xz
Installing Python-3.9.5...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Ubuntu 21.04 using python-build 1.2.27-7-g1edded34)

Inspect or clean up the working tree at /tmp/python-build.20210505173738.7298
Results logged to /tmp/python-build.20210505173738.7298.log

Last 10 log lines:
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmp269bylh7
Processing /tmp/tmp269bylh7/setuptools-56.0.0-py3-none-any.whl
Processing /tmp/tmp269bylh7/pip-21.1.1-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.9 are installed in '/home/dylan/.asdf/installs/python/3.9.5/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.1 setuptools-56.0.0

Solution - Install prerequisite build tools

After some digging I found the following combination to get me over the hump:

1
2
3
4
sudo apt install build-essential libssl-dev \
  zlib1g-dev libbz2-dev libreadline-dev \
  libsqlite3-dev llvm libncurses5-dev \
  libncursesw5-dev wget curl

With that in place this completed successfully:

1
2
3
4
5
6
$ asdf install python 3.9.5
python-build 3.9.5 /home/dylan/.asdf/installs/python/3.9.5
Downloading Python-3.9.5.tar.xz...
-> https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tar.xz
Installing Python-3.9.5...
Installed Python-3.9.5 to /home/dylan/.asdf/installs/python/3.9.5

See Also