DEV Community

Waylon Walker
Waylon Walker

Posted on • Originally published at waylonwalker.com

pyenv no module named '_sqlite3'

I've been trying to adopt pyenv for a few months, but have been completely blocked by this issue on one of the main machines I use. Whenever I start up ipython I get the following error.



ImportError: No module named '_sqlite3


Enter fullscreen mode Exit fullscreen mode

I talked about why and how to use pyenv along with my first impressions in this post

pyenv/issues/678

According to #678 I need to install libsqlite3-dev on ubuntu to resolve this issue.

install libsqlite3-dev

libsqlite3-dev can be installed using apt



sudo apt install libsqlite3-dev


Enter fullscreen mode Exit fullscreen mode

But wait....

When I make a fresh env and install ipython I still get the same error and I am still not able to use ipython with pyenv.



ImportError: No module named '_sqlite3


Enter fullscreen mode Exit fullscreen mode

re-install python

After having this issue for awhile an coming back to #678 several times I realized that
libsqlite3-dev needs to be installed while during install.



pyenv install 3.8.13


Enter fullscreen mode Exit fullscreen mode

I think I had tried this several times, but was missing the -y option each time. You gotta read errors like this, I am really good at glossing over them.

pyenv-install-exists

Let's never have this issue again.

When you spend months living with little errors like this and finally fix it, its good to make sure that it never happens again. Whenever I start a new ubuntu machine I run an ansible playbook that does all the setup for me. I added libsqlite3-dev to my core install in 64c85ca now it will be on all of my machines and not break again.

Top comments (1)

Collapse
 
markboer profile image
Mark Boer

The pyenv wiki lists the advised build environment for different Linux distros, that typically solves these kind of issues :-).

github.com/pyenv/pyenv/wiki

Happy coding!