DLLs loading in interpreter but not with direct run on Windows

J

JTimoty

Hi,

I've got a weird problem, apparently related to the way python
searches for DLLs on Windows.

I compiled PyQt4 (no errors) but scripts that use it fail with "DLL
load failed: Invalid access to memory location."
If I play with loading the modules inside the interpreter, I see no
errors.

Even more, if I use IDLE, running scripts fails. However, if I _first_
type "from PyQt4 import QtGui" in the python shell, the script
executes without problems.

What is the difference between these two cases? How is loading dlls
different in ( $> python script.py ) and just ( $> python )?

Thanks,
Tim.
 
T

TerryP

Hi,

I've got a weird problem, apparently related to the way python
searches for DLLs on Windows.

I compiled PyQt4 (no errors) but scripts that use it fail with "DLL
load failed: Invalid access to memory location."
If I play with loading the modules inside the interpreter, I see no
errors.

Even more, if I use IDLE, running scripts fails. However, if I _first_
type "from PyQt4 import QtGui" in the python shell, the script
executes without problems.

I have the batch file that sets up my python 2 and python 3 sessions,
each append the site-packages\PyQt4 directory to my %Path%, so that
Windows will definitely be able to see the (Py)Qt DLL files located
there.

If you take a look at the PyQt4 package, __init__.py is just a stub.
I'm not familiar with SIP, so I don't know what pyqtconfig.py does.
Everything that you import however, is basically the name of a .pyd
and .dll file there. E.g. from pyQt4 import QtGui = there is a
QtGui.pyd and QtGui.dll module.

The .pyd file is what you're really importing, but I don't recall the
relationship to the dll files clumped around it. You can probably find
it in the python or windows manuals somewhere.

What is the difference between these two cases? How is loading dlls
different in ( $> python script.py ) and just ( $> python )?

Thanks,
Tim.

Example from my system:
vim test.py
python test.py
['My CWD', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Dev
Files\\Languages\\Python\\26\\DLLs', 'C:\\DevFiles\\Languages\\Python\
\26\\lib', 'C:\
\DevFiles\\Languages\\Python\\26\\lib\\plat-win', 'C:\\DevFiles\
\Languages\\Python\\2
6\\lib\\lib-tk', 'C:\\DevFiles\\Languages\\Python\\26', 'C:\\DevFiles\
\Languages\\Pyt
hon\\26\\lib\\site-packages', 'C:\\DevFiles\\Languages\\Python\\26\\lib
\\site-package
s\\gtk-2.0']
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit
(Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.['', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\DevFiles\\Languages\
\Python\\26\\DLL
s', 'C:\\DevFiles\\Languages\\Python\\26\\lib', 'C:\\DevFiles\
\Languages\\Python\\26\
\lib\\plat-win', 'C:\\DevFiles\\Languages\\Python\\26\\lib\\lib-tk',
'C:\\DevFiles\\L
anguages\\Python\\26', 'C:\\DevFiles\\Languages\\Python\\26\\lib\\site-
packages', 'C:
\\DevFiles\\Languages\\Python\\26\\lib\\site-packages\\gtk-2.0']
I also note that there is no python26.zip file in %SystemRoot%
\system32, just DLL files corresponding to each version of Python I
have installed.
 
J

JTimoty

Sorry guys, the problem seems to be less general.

Actually, the error is triggered when I try to import numpy before
PyQt4. It imports without any problems after PyQt4.

I still don't know what the problem actually is, but at least my
scripts work.

Thanks,

Tim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top