Reputation: 3243
Can someone tell me how to install the sqlite3 module alongside the most recent version of Python? I am using a Macbook, and on the command line, I tried:
pip install sqlite
but an error pops up.
Upvotes: 186
Views: 671741
Reputation: 470
For Jupyter Notebook
and pyenv
users I found this:
https://github.com/jupyterlab/jupyterlab/issues/4181
So basically sqlite3 did not come with python 3.6 or something of that sort
You need to:
sudo apt install libsqlite3-dev
pyenv install 3.6
Upvotes: 1
Reputation: 570
sqlite3 automatically comes with python. You can upgrade python version if you need latest version of sqlite3 or follow steps from https://www.sqlite.org/download.html
Upvotes: -3
Reputation: 2302
For Windows + Conda users: you have to download the sqlite3 dll, uncompress and copy the file into the DLL dir in Conda installion path
Check this answer for more detail
Upvotes: 0
Reputation: 3096
Normally, it is included. However, as @ngn999 said, if your python has been built from source manually, you'll have to add it.
Here is an example of a script that will setup an encapsulated version (virtual environment) of Python3 in your user directory with an encapsulated version of sqlite3.
INSTALL_BASE_PATH="$HOME/local"
cd ~
mkdir build
cd build
[ -f Python-3.6.2.tgz ] || wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
tar -zxvf Python-3.6.2.tgz
[ -f sqlite-autoconf-3240000.tar.gz ] || wget https://www.sqlite.org/2018/sqlite-autoconf-3240000.tar.gz
tar -zxvf sqlite-autoconf-3240000.tar.gz
cd sqlite-autoconf-3240000
./configure --prefix=${INSTALL_BASE_PATH}
make
make install
cd ../Python-3.6.2
LD_RUN_PATH=${INSTALL_BASE_PATH}/lib configure
LDFLAGS="-L ${INSTALL_BASE_PATH}/lib"
CPPFLAGS="-I ${INSTALL_BASE_PATH}/include"
LD_RUN_PATH=${INSTALL_BASE_PATH}/lib make
./configure --prefix=${INSTALL_BASE_PATH}
make
make install
cd ~
LINE_TO_ADD="export PATH=${INSTALL_BASE_PATH}/bin:\$PATH"
if grep -q -v "${LINE_TO_ADD}" $HOME/.bash_profile; then echo "${LINE_TO_ADD}" >> $HOME/.bash_profile; fi
source $HOME/.bash_profile
Why do this? You might want a modular python environment that you can completely destroy and rebuild without affecting your managed package installation. This would give you an independent development environment. In this case, the solution is to install sqlite3 modularly too.
Upvotes: 29
Reputation: 781
if you have error in Sqlite built in python you can use Conda to solve this conflict
conda install sqlite
Upvotes: 7
Reputation: 778
I have python 2.7.3 and this solved my problem:
pip install pysqlite
Upvotes: 43