Friday, August 29, 2014

Re: Error importing dbapi2 (SOLVED)...

I figured it out. 


I had set environment variable PYTHONPATH to help Django
find the sql_server.pyodbc files needed to make a connection
to a Microsoft SQL Server DB.  This was keeping SQLite from
working properly.  When I cleared the environment variable,
SQLite works fine.

I now get no errors when I do:
    >>> import sqlite3
    >>> from sqlite3 import dbapi2

and I no longer get the error about dbapi2 when I run my
regression tests via Django.

To get the sql_server.pyodbc file to be found, I now use a
    % ln -s django/db/backends/sql_server \
instead of setting PYTHONPATH:
    % setenv PYTHONPATH ~/python/virtualenvs/hhl/lib/python2.7/site-packages/django/db/backends

Fred Stluka -- --
Bristle Software, Inc -- -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
On 8/25/14 9:30 AM, Fred Stluka wrote:
I'm getting error:

Error loading either pysqlite2 or sqlite3 modules
(tried in that order): cannot import name dbapi2

Any suggestions?


My contains:
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/Users/fred/fred/HHL/HHLWeb/sqlite3.db'

Works fine with other DBs (MySQL, MS SQL Server, etc.), but now
I'm trying to switch to SQLite for faster testing.

From the command line, I can see that sqlite3 is installed
(by default as part of the Django install), but seems to not
contain dbapi2:

>>> import sqlite3
>>> from sqlite3 import dbapi2
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: cannot import name dbapi2

Any ideas for me?  Any suggestions on how to narrow down
the problem?  Any more info I should give you?


No comments:

Post a Comment