Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Embedded python 2.6 interpreter can't "import sqlite3" on Windows XP

Reply
Thread Tools

Embedded python 2.6 interpreter can't "import sqlite3" on Windows XP

 
 
jdetaeye
Guest
Posts: n/a
 
      02-01-2009

I am porting an application which embeds a Python interpreter to
Python 2.6.
On version 2.5 all is working fine, but importing the sqlite3 module
doesn't work any more on 2.6.

The statement "import sqlite3" does work fine when executed from in
the python command prompt, ie not from the embedded interpreter.
The same import gives the following error when executed from the
embedded interpreter.
Python stacktrace:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "C:\Python26\lib\sqlite3\__init__.py", line 24, in
<module>
from dbapi2 import *
File "C:\Python26\lib\sqlite3\dbapi2.py", line 27, in
<module>
from _sqlite3 import *
ImportError: DLL load failed: A dynamic link library (DLL)
initialization routine failed.
Windows popup window:
Runtime Error!
R6034
An application has made an attempt to load the C runtime
library incorrectly.
Please contact the application's support team for more
information.

Unfortunately the "application support team" (that is me has no
idea on how to move forward on this:
a) I guess this is releated to the problem with manifest files,
already reported in http://bugs.python.org/issue4120 ?
b) What could be a solution or workaround for the problem?

All the above is on Windows XP.
Other modules with have an extension DLL (such as ssl) give exactly
the same problem.

All help appreciated,

Johan

 
Reply With Quote
 
 
 
 
Peter
Guest
Posts: n/a
 
      02-01-2009
jdetaeye wrote:
> I am porting an application which embeds a Python interpreter to
> Python 2.6.
> On version 2.5 all is working fine, but importing the sqlite3 module
> doesn't work any more on 2.6.
>
> The statement "import sqlite3" does work fine when executed from in
> the python command prompt, ie not from the embedded interpreter.
> The same import gives the following error when executed from the
> embedded interpreter.
> Python stacktrace:
> Traceback (most recent call last):
> File "<string>", line 2, in <module>
> File "C:\Python26\lib\sqlite3\__init__.py", line 24, in
> <module>
> from dbapi2 import *
> File "C:\Python26\lib\sqlite3\dbapi2.py", line 27, in
> <module>
> from _sqlite3 import *
> ImportError: DLL load failed: A dynamic link library (DLL)
> initialization routine failed.
> Windows popup window:
> Runtime Error!
> R6034
> An application has made an attempt to load the C runtime
> library incorrectly.
> Please contact the application's support team for more
> information.
>
> Unfortunately the "application support team" (that is me has no
> idea on how to move forward on this:
> a) I guess this is releated to the problem with manifest files,
> already reported in http://bugs.python.org/issue4120 ?
> b) What could be a solution or workaround for the problem?
>
> All the above is on Windows XP.
> Other modules with have an extension DLL (such as ssl) give exactly
> the same problem.
>
> All help appreciated,
>
> Johan
>


Python 2.6+ was built with Visual Studio 2008; therefore, the Microsoft
Visual C++ 2008 Redistributable Package (run time libraries) must be
installed on the computer that you are trying to run your python
application. If the computer already has Python 2.6+ installed "for all
users", then the run time libraries should already be installed in
c:\windows\winsxs. On computers that do not have Python 2.6+ installed
(or it was installed using "Install Just for Me"), you probably will
need to install the Visual C++ 2008 Redistributable Package. It is
possible that some other application already installed the correct run
time libraries in the c:\windows\winsxs directory.

Visual C++ 2008 Redistributable Package:
http://www.microsoft.com/downloads/d...displaylang=en

After installing the Visual C++ 2008 Redistributable, you can find it
under the c:\windows\winsxs directory.

Side-by-Side (sxs) Assemblies are Microsoft's answer to "DLL hell" and
Visual C++ 2005 had them, too. I believe the reason the Python
community didn't see these problems earlier was that most computers
already had the proper run time libraries installed. See "Application
Compatibility—Side-by-side Assemblies" in
http://msdn.microsoft.com/en-us/magazine/cc302206.aspx and
http://msdn.microsoft.com/en-us/magazine/ms997620.aspx for more
information on Side-by-Side Assemblies.

Note that if future versions of Python are built with Visual Studio 2008
with service pack (SP) #x and the build specifies that the SP #x updated
run time libraries should be used, then you'll need to install the
updated run time libraries. See
http://msdn.microsoft.com/en-us/library/cc664727.aspx and
http://msdn.microsoft.com/en-us/libr...99(VS.80).aspx for more
information on binding applications to specific run time libraries.

The following articles may also be of interest:

http://msdn.microsoft.com/en-us/library/ms235531.aspx
http://msdn.microsoft.com/en-us/library/ms235342.aspx
http://msdn.microsoft.com/en-us/library/aa374224.aspx

Of course everything I've just said may change with the next release of
Python, because the Python maintainers are apparently looking at
alternative ways around this issue. Although I'm not a Microsoft fan,
I'm not yet convinced that trying to work around Microsoft's winsxs
requirements is a smart thing to do.

It might simplify things for python users and developers if the Python
2.6+ installers always installed the VS C++ run time libraries into the
winsxs directory. Perhaps python tools that create embedded python
applications could better document this issue, so that people using
embedded applications will know that they have to install the proper run
time libraries. It's also possible that Microsoft will someday install
these new Visual Studio 2008 run time libraries via their update service
or a future service pack.

Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python embedded interpreter: how to initialize the interpreter ? ycollet@freesurf.fr Python 3 01-03-2007 01:00 AM
Debugging of Python code in embedded interpreter TK Python 1 11-30-2005 04:05 PM
Embedded Python interpreter and sockets wahn@acm.org Python 4 11-23-2005 01:15 AM
Embedded Python interpreter, runtime libs, and crashing Peter Newman Python 1 10-26-2005 03:38 AM
embedded python and interpreter threads Charlie DeTar Python 2 12-07-2004 04:52 PM



Advertisments