Python & Django: No module named _sqlite3

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Python & Django: No module named _sqlite3

Tom Simons
Python newbie here - I've been replacing our awk & ksh scripts for reports with it.  I liked the Django demo on Windows so much that I volunteered to implement our tiny website using Django on RHEL AS5 Linux boxes.

Now I'm running into trouble getting Python, Django, & SQLite working on RHEL AS5.  I don't really require compiling from source, but I did so to get the latest versions (& I thought Python > 2.5 came with SQLite already installed).

What am I missing in the installs below? The Django "manage.py syncdb" gets error "No module named _sqlite3". 

Does Django installation require more than the link to Python-2.7/lib/python2.7/site-packages?

$ tar xf Python-2.7.tgz                      #Install Python 2.7
$ cd Python-2.7
$ mkdir           /apps/Python-2.7
$ chown simonst   /apps/Python-2.7
$ ./configure --prefix=/apps/Python-2.7
$ make
$ sudo make install
$ export PATH=/apps/Python-2.7/bin:$PATH
$ python -V
Python 2.7


$ tar xzf sqlite-amalgamation-3.7.0.1.tar.gz #Install sqlite 3.7.0.1
$ cd sqlite-3.7.0.1
$ ./configure --prefix=/apps/sqlite-3.7.0
$ make
$ sudo make install
$ export PATH=/apps/sqlite-3.7.0/bin:$PATH
$ sqlite3 -version
3.7.0.1

$ sudo tar xzf Django-1.2.1.tar.gz -C /apps  #Install Django 1.2.1
$ cd /apps/Django-1.2.1
$ sudo ln -s /apps/Django-1.2.1/django /apps/Python-2.7/lib/python2.7/site-packages
$ export PATH=/apps/Django-1.2.1/django/bin:$PATH
$ django-admin.py --version
1.2.1

 (see attachment for more detail)

$ django-admin.py startproject mysite        #Start Django project
$ cd mysite
$ ./manage.py runserver                      #Show Django dev server is ok
$ ./manage.py startapp blog                  #Start Django Blog app
$ vi  blog/models.py
$ vi settings.py

$ ./manage.py syncdb                         #Build database
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
  .  .  .  .  .
  File "/apps/Python-2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 34, in <module>
    raise ImproperlyConfigured("Error loading %s: %s" % (module, exc))
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3


_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies

django_sqlite_error.txt (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Python & Django: No module named _sqlite3

Rami Chowdhury
Hey Tom,

Welcome to Python!

On Aug 16, 2010, at 23:43 , Tom Simons wrote:


What am I missing in the installs below? The Django "manage.py syncdb" gets error "No module named _sqlite3". 

Does Django installation require more than the link to Python-2.7/lib/python2.7/site-packages?


It shouldn't -- what does your Python path (sys.path) look like?



-------------
Rami Chowdhury
"Never assume malice when stupidity will suffice." -- Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)


_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies
Reply | Threaded
Open this post in threaded view
|

Re: Python & Django: No module named _sqlite3

Simeon Franklin
In reply to this post by Tom Simons
See http://stackoverflow.com/questions/233320/cannot-import-sqlite-with-python-2-6

It looks like there are problems building python from source with
sqlite3 support if the sqlite dev headers aren't installed. Can you
find the missing .so file ($ locate _sqlite3.so)? If so I would
symlink it into the python site-packages directory...

-regards
Simeon Franklin


On Mon, Aug 16, 2010 at 10:43 AM, Tom Simons <[hidden email]> wrote:

> Python newbie here - I've been replacing our awk & ksh scripts for reports
> with it.  I liked the Django demo on Windows so much that I volunteered to
> implement our tiny website using Django on RHEL AS5 Linux boxes.
>
> Now I'm running into trouble getting Python, Django, & SQLite working on
> RHEL AS5.  I don't really require compiling from source, but I did so to get
> the latest versions (& I thought Python > 2.5 came with SQLite already
> installed).
>
> What am I missing in the installs below? The Django "manage.py syncdb" gets
> error "No module named _sqlite3".
>
> Does Django installation require more than the link to
> Python-2.7/lib/python2.7/site-packages?
>
> $ tar xf Python-2.7.tgz                      #Install Python 2.7
> $ cd Python-2.7
> $ mkdir           /apps/Python-2.7
> $ chown simonst   /apps/Python-2.7
> $ ./configure --prefix=/apps/Python-2.7
> $ make
> $ sudo make install
> $ export PATH=/apps/Python-2.7/bin:$PATH
> $ python -V
> Python 2.7
>
>
> $ tar xzf sqlite-amalgamation-3.7.0.1.tar.gz #Install sqlite 3.7.0.1
> $ cd sqlite-3.7.0.1
> $ ./configure --prefix=/apps/sqlite-3.7.0
> $ make
> $ sudo make install
> $ export PATH=/apps/sqlite-3.7.0/bin:$PATH
> $ sqlite3 -version
> 3.7.0.1
>
> $ sudo tar xzf Django-1.2.1.tar.gz -C /apps  #Install Django 1.2.1
> $ cd /apps/Django-1.2.1
> $ sudo ln -s /apps/Django-1.2.1/django
> /apps/Python-2.7/lib/python2.7/site-packages
> $ export PATH=/apps/Django-1.2.1/django/bin:$PATH
> $ django-admin.py --version
> 1.2.1
>
>  (see attachment for more detail)
>
> $ django-admin.py startproject mysite        #Start Django project
> $ cd mysite
> $ ./manage.py runserver                      #Show Django dev server is ok
> $ ./manage.py startapp blog                  #Start Django Blog app
> $ vi  blog/models.py
> $ vi settings.py
>
> $ ./manage.py syncdb                         #Build database
> Traceback (most recent call last):
>   File "./manage.py", line 11, in <module>
>   .  .  .  .  .
>   File
> "/apps/Python-2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py",
> line 34, in <module>
>     raise ImproperlyConfigured("Error loading %s: %s" % (module, exc))
> django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2
> or sqlite3 modules (tried in that order): No module named _sqlite3
>
>
> _______________________________________________
> Baypiggies mailing list
> [hidden email]
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
>
_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies
Reply | Threaded
Open this post in threaded view
|

Re: Python & Django: No module named _sqlite3

William Deegan-2
In reply to this post by Rami Chowdhury
Tom,

You may want to take a look at setuptools and easy_install for installing modules.
It will pull the dependencies for you (like CPAN).
In this case your python build may not have picked up the location you installed sqlite3 at.

./configure --help on python to see if there's a flag to specify where sqlite3 lives.
You'll likely need to rebuild.

-Bill

On Mon, Aug 16, 2010 at 11:13 AM, Rami Chowdhury <[hidden email]> wrote:
Hey Tom,

Welcome to Python!

On Aug 16, 2010, at 23:43 , Tom Simons wrote:


What am I missing in the installs below? The Django "manage.py syncdb" gets error "No module named _sqlite3". 

Does Django installation require more than the link to Python-2.7/lib/python2.7/site-packages?


It shouldn't -- what does your Python path (sys.path) look like?



-------------
Rami Chowdhury
"Never assume malice when stupidity will suffice." -- Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)


_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies


_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies
Reply | Threaded
Open this post in threaded view
|

Re: Python & Django: No module named _sqlite3

Michael Pittaro-3
When building Python from source, I have developed the habit of running the tests after the build

> ./configure ....
> make
> make test

The test output will tell you which modules weren't built, and which test skips were unexpected.

I think Simeon was going in the right direction; the sqlite modules probably didn't build because the development headers are missing. 




_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies
Reply | Threaded
Open this post in threaded view
|

Re: Python & Django: No module named _sqlite3

William Deegan-2
All,

If you modify setup.py around line 973, you can add the include path for your install of sqlite.
Do that , make distclean, and then do configure, make, make test.
I'm surprised there's no flag for configure to point to it.

-Bill

On Mon, Aug 16, 2010 at 12:03 PM, Michael Pittaro <[hidden email]> wrote:
When building Python from source, I have developed the habit of running the tests after the build

> ./configure ....
> make
> make test

The test output will tell you which modules weren't built, and which test skips were unexpected.

I think Simeon was going in the right direction; the sqlite modules probably didn't build because the development headers are missing. 




_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies


_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies
Reply | Threaded
Open this post in threaded view
|

Re: Python & Django: No module named _sqlite3

Andy Wiggin
In reply to this post by Michael Pittaro-3
I had what sounds like a similar problem when building my own sqlite
and Python 2.5.4. I believe the root problem was that the Python build
script could not find the sqlite header files so the _sqlite3.so was
not built. My solution was simply to add the correct C compiler flag
to the standard env variable before calling configure for Python. E.g.
(using csh):

setenv CPPFLAGS -I/my-root-path/sqlite3/include
./configure ...
make
make install

As suggested, there may be a way to accomplish the same thing using
./configure options, etc.

Regards,
Andy

On Mon, Aug 16, 2010 at 12:03 PM, Michael Pittaro
<[hidden email]> wrote:

> When building Python from source, I have developed the habit of running the
> tests after the build
>
>> ./configure ....
>> make
>> make test
>
> The test output will tell you which modules weren't built, and which test
> skips were unexpected.
>
> I think Simeon was going in the right direction; the sqlite modules probably
> didn't build because the development headers are missing.
>
>
>
>
> _______________________________________________
> Baypiggies mailing list
> [hidden email]
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
>
_______________________________________________
Baypiggies mailing list
[hidden email]
To change your subscription options or unsubscribe:
http://mail.python.org/mailman/listinfo/baypiggies