Python 3.3 source code setup: modules were not found: _lzma _sqlite3 _tkinter

Viewed 18694

I am trying to set up the compiled version of CPython, on Ubuntu 12.04, by following the python developer guide. Even after installing the dependent packages lzma and sqlite3, build fails indicating that the dependent modules were not found. Exact Error:

*Python build finished, but the necessary bits to build these modules were not found: _lzma _sqlite3 _tkinter
To find the necessary bits, look in setup.py in detect_modules() for the module's name.*

I could not locate the package tkinter. Appreciate any help.

6 Answers

In general, see Python Developer's Guide for dependencies. There it says:

"If you want to build all optional modules, install the following packages and their dependencies":

sudo apt-get install build-essential gdb lcov pkg-config \
  libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
  libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
  lzma lzma-dev tk-dev uuid-dev zlib1g-dev

Struggled a bit with this on Ubuntu 20.04 in 2021 (in case anyone lands here looking for a newer set of instructions). Found this article that was very useful:

https://linoxide.com/ubuntu-how-to/install-python-3-9-on-ubuntu-20-04-lts/

On Ubuntu you can install the dependencies with apt so it's just a matter of knowing which. The build commands I used were the following:

# Update repo, very important on fresh server install
apt update
# Install dependencies
apt install gcc build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev
# Configure with optimizations
./configure --enable-optimizations
make -j 4 # 4 cores
make test # Shows you anything you missed
# https://docs.python.org/3/using/unix.html#building-python 
make altinstall

I chose not to install sqlite or tkinter because I didn't need them, but the process is the same. Just include those dependencies found in @simp76's answer.

I just ran through this process on a fresh install of Ubuntu 20.04 on a DO droplet and it worked flawlessly.

Related