NaveenBabuE
NaveenBabuE

Reputation: 776

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

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.

Upvotes: 18

Views: 23226

Answers (6)

vfinn
vfinn

Reputation: 170

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

Upvotes: 9

nicorellius
nicorellius

Reputation: 4043

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.

Upvotes: 0

Al Conrad
Al Conrad

Reputation: 1618

I used the instructions here: python-on-debian-wheezy

But I also had to install tk-dev which wasn't listed there.

Upvotes: 0

Giampaolo Rodolà
Giampaolo Rodolà

Reputation: 13056

This works for me (Python 3.4, Ubuntu 13.04) meaning "make" completes cleanly:

sudo apt-get install build-essential python-dev libncurses*-dev \
                     liblzma-dev libgdbm-dev libsqlite3-dev \
                     libbz2-dev tk-dev

Install:

cd python3.4
make clean && ./configure && make && sudo make install

Upvotes: 1

gusaki
gusaki

Reputation: 739

I was able to build Python 3.3 without modifying setup.py after installing the following packages on my Ubuntu Precise box.

build-essential 
zlib1g-dev 
libbz2-dev 
libncurses5-dev 
libreadline6-dev 
libsqlite3-dev 
libssl-dev 
libgdbm-dev
liblzma-dev
tk8.5-dev

Upvotes: 28

user707650
user707650

Reputation:

The lack of finding lzma and sqlite3 may be because your paths (LD_LIBRARY_PATH in particular) were incorrect. How did you install those two packages; did you use the package manager? If you installed manually, where did you install them? Also, did you install the development versions, if you used the package manager to install lzma and sqlite3? When installing from source, you'll need the development versions, so Python's source can find the necessary include files.

Further, you may have to edit setup.py to indicate where these packages can be found.

As for tkinter: this relies on tcl/tk, so check that you have the development versions of these packages installed if you're installing python/tkinter from source.

Upvotes: 2

Related Questions