WARNING: IPython history requires SQLite, your history will not be saved

Hi, I am using Ubuntu release 12.10 (quantum) 32-bit with Linux Kernel 3.5.0-21-generic. I am trying to get IPython History to work. I installed it using pythonbrew and a virtual environment. There I use pip to install IPython. Currently, when I run IPython in a terminal, I get:

WARNING: IPython History requires SQLite, your history will not be saved Python 2.7.3 (default, Nov 8 2012, 18:25:10) Type "copyright", "credits" or "license" for more information. IPython 0.13.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython features. %quickref -> Quick reference. help -> Python own help system. object? -> Details about 'object', use 'object??' for extra details. 

Searching for a warning in the first line, I found this release , so I went back and installed the following:

 sudo apt-get install libsqlite0 libsqlite0-dev libsqlite3-0 libsqlite3-dev 

and then uninstall and reinstall pysqlite using pip

 pip uninstall pysqlite pip install pysqlite 

After that, I decided to check the installation by importing the module:

 Python 2.7.3 (default, Nov 8 2012, 18:25:10) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/me/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/sqlite3/__init__.py", line 24, in <module> from dbapi2 import * File "/home/me/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module> from _sqlite3 import * ImportError: No module named _sqlite3 

So now the _sqlite3.so file seems impossible. This is when I found this SO question . Either it does not exist or it is not in my PYTHONPATH environment variable. File search, I get:

 $ locate _sqlite3.so /home/me/Desktop/.dropbox-dist/_sqlite3.so /home/me/epd/lib/python2.7/lib-dynload/_sqlite3.so /usr/lib/python2.7/lib-dynload/_sqlite3.so 

So there is a file, but when I looked at my python path:

 import sys for p in sys.path: print p 

none of the above paths containing _sqlite3.so were contained in my PYTHONPATH. For a giggle, I added the path / usr / lib / python 2.7 / lib-dynload to my PYTHONPATH in the terminal, and then tried to import sqlite3 again:

 Python 2.7.3 (default, Nov 8 2012, 18:25:10) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path.append("/usr/lib/python2.7/lib-dynload") >>> import sqlite3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/me/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/sqlite3/__init__.py", line 24, in <module> from dbapi2 import * File "/home/me/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module> from _sqlite3 import * ImportError: /usr/lib/python2.7/lib-dynload/_sqlite3.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8 

Oh oh Now I'm completely stuck. Can someone help me? I also read in several places that I might have to rebuild Python. I don't know how to do this in pythonbrew. Can someone point me in the right direction?

+10
source share
5 answers

Thanks to minrk for pointing me in the right direction. All I needed to do was rebuild python. I have outlined the following steps for those using pythonbrew. Please note that I have already installed the libsqlite3-dev package in the question section.

First, when loading the correct version of bootable python and virtual environment, run the command:

 $ pip freeze -l > requirements.txt 

This gives us a list of text files of all the package packages that were installed in the virtual environment for this particular version of python in pythonbrew. Then we uninstall the python version from pythonbrew and reinstall it (this is the "rebuild python" step):

 $ pythonbrew uninstall 2.7.3 $ pythonbrew install 2.7.3 

After that, we switch to the recently installed version of python 2.7.3 and create a new virtual environment (which I called "sci"):

 $ pythonbrew switch 2.7.3 $ pythonbrew venv create sci $ pythonbrew venv use sci 

Ideally, you should be able to run the command:

 $ pip install -r requirements.txt 

and according to this, pip must reinstall all the modules that you had in the virtual environment before we hide this version of python (2.7.3). For me, this did not work for any reason, so I manually installed all the modules using the pip personality.

 $ ipython --pylab Python 2.7.3 (default, Jan 5 2013, 18:48:27) Type "copyright", "credits" or "license" for more information. IPython 0.13.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython features. %quickref -> Quick reference. help -> Python own help system. object? -> Details about 'object', use 'object??' for extra details. 

and the ipython story works!

+7
source

I also read in several places that I might have to rebuild Python.

It is right. SQLite is part of the standard library, and is created when compiling Python. There are several β€œoptional” parts of the standard library that Python will simply skip (with minimal warning, unfortunately) if there are no dependencies during the build, and sqlite is one of them. You should just install libsqlite3-dev , then rebuild Python, and you should be installed. Watch for build messages as they tell you which modules they skip due to lack of dependencies.

+9
source

What worked for me (using osx + homebrew + brewing python):

 # Reinstall Python 2.7 with sqlite brew remove python brew install readline sqlite gdbm --universal brew install python --universal --framework # Reinstall iPython with correct bindings pip uninstall ipython pip install ipython 

And you should be good to go.

+4
source

You must restore your python with sqlite support

 sudo apt-get install libsqlite3-dev wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz tar -xvf Python-2.7.15.tgz cd Python-2.7.15 ./configure make sudo make install 

Re-create your virtual environment and you should be ready

 rmvirtualenv venv mkvirtualenv -p python2 venv workon venv pip install -r requirements.txt # or pip install ipython 
+1
source

This warning appears on macOS when python is installed with pyenv. By default, it installs Python without sqlite. These commands reinstall python with sqlite support:

 pyenv uninstall 3.7 CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.7 
0
source

All Articles