3

No module named sqlite

 3 years ago
source link: https://www.codesd.com/item/no-module-named-sqlite.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

No module named sqlite

advertisements

i am a beginner i need to create a python virtual_environment for installing Django. I am using the following steps for installing python and virtualenv

cd /usr/src/
wget http://www.python.org/ftp/python/3.5.1./Python-3.5.1.tgz
tar zxf Python-3.5.1.tgz
cd python-3.5.1
mkdir /usr/local/python-3.5
./configure --prefix=/usr/local/python'.$python.' --with-threads --enable-shared --with-zlib=/usr/include && make && make altinstall
echo "/usr/local/python3.5/lib" > python3.5.conf
mv python3.5.conf /etc/ld.so.conf.d/python3.5.conf
/sbin/ldconfig
ln -sfn /usr/local/python3.5/bin/python3.5 /usr/bin/python3.5
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.tar.gz
tar xzf setuptools-11.3.1.tar.gz
cd setuptools-11.3.1
/usr/local/python3.5/bin/python3.5 setup.py install
/usr/local/python3.5/bin/easy_install-3.5 pip
ln -sfn /usr/local/python3.5/bin/pip3.5 /usr/bin/pip3.5
/usr/local/python3.5/bin/pip3.5 install virtualenv

then i am created a virtualenv based on this, and enter into python shell and use

import sqlite

i got following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'sqlite'

And i tried to run a django project installed in the virtalenv i got following errors.

raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named '_sqlite3'

I am using CentOS release 6.8 (Final).


The python-bundled sqlite package is called sqlite3: https://docs.python.org/3.6/library/sqlite3.html

So, just do

import sqlite3

and you should be good.

EDIT

I only now realized that you're building python yourself. So that's probably why the sqlite3 module is missing. Check the output of the configure call whether sqlite3 is mentioned. I assume you'd have to get the development packages.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK