Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

PyWin32/Tix problem, also Python for Delphi

This may get a little convoluted, and spans a couple of topics (I'm posting in both Python and Delphi).

I have written a Delphi  application which does PC/SC card reader control and machine control via I/O cards.  It runs a scripter which allows the machine control to make servos pass cards over readers, do things to the cards (initialize them, get data from a database and write to them, log results to a database, etc.)

The application uses Python 2.4 and the Python for Delphi interface.  I have written a small library of Python functions the user can load and call.  Each script runs at a different point in a production line, talking to PLCs to move the line, and the readers to manage the cards.

There is a wish to make a QA station with user interface.  Although I can make extensions which will give me Delphi forms, it will be hard to make this user-extensible via the scripter.  If I allow the user to use Tix, however, the script writer can build and modify the user interface without modifying source code.

I installed Tix on my PC, using the binary installation which comes with "IDEStudio".  I can run IDEstudio, and the demos, in their directory.

However, when I try to run Tix in Python for Windows, or in my Delphi application, I get the same error:

>>> import Tix
>>> root = Tix.Tk()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\python24\lib\lib-tk\Tix.py", line 210, in __init__
    self.tk.eval('package require Tix')
TclError: couldn't load library "C:/python24/tcl/tix8.1/tix8183.dll": this library or a dependent library could not be found in library path
>>> 

However, "C:/python24/tcl/tix8.1/tix8183.dll" does in fact exist, as does the required package file pkgIndex.tcl.  I have set the environment variables TIX_LIBRARY and PYTHONHOME to their proper values (PYTHONHOME was needed to get the TIX examples in IDEStudio to work).  I have tried making the slashes in both directions (C:/ and C;\), and doubling them.  Nothing makes it find the DLL.

I feel as though I'm missing something very small and probably very obvious, but as I'm in a hurry, I'll throw a lot of points at this.
0
sburck
Asked:
sburck
  • 4
  • 3
1 Solution
 
RichieHindleCommented:
Download Dependency Walker (www.dependencywalker.com) and load C:/python24/tcl/tix8.1/tix8183.dll into it.  That will tell you which of its dependencies is missing.
0
 
sburckAuthor Commented:
Richie - Did it, found a couple of missing DLLs which I brought into the directory...Dependencywalker shows now only a warning:

Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

The warning is about MPR.DLL (system) and highlighting the function WNetRestoreConnectionA.

But inany case, the problem still exists exactly as it was, even with all necessary DLLs in place.
0
 
RichieHindleCommented:
I wouldn't worry too much about MPR.DLL - I've seen that one a lot and I don't think it matters.

Dependency Walker has a Profile feature that lets you run a program under the control of Dependency Walker, which watches all the DLLs as they load and will report errors that the static checking won't detect.  Try profiling Python in this way - you'll need to set up the command line and so on within Dependency Walker.  In order to pick up your environment variables, you might need to start Dependency Walker from your command line.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
BlackTigerXCommented:
you can try modifying the system path as well to include that path, in Windows XP:

- press Windows Key+Pause (nice trick uh), or right click on "My computer", properties
- Advanced
- Environment Variables
- System variables
- edit the PATH there

just in case you miss other files from that directory
0
 
RichieHindleCommented:
BlackTigerX: "Windows Key+Pause (nice trick uh)" - cool!  I didn't know about that.
0
 
sburckAuthor Commented:
OK, I got called off onto something else, and got back to this:  I run while profiling, and thpe in two lines:  import Tix followed by root=Tix.Tk().

What I see is this (I'm flagging with ***** lines that are in red):

Loaded "_TKINTER.PYD" at address 0x01890000.  Successfully hooked module.
Loaded "TK84.DLL" at address 0x10220000.  Successfully hooked module.
Loaded "TCL84.DLL" at address 0x018A0000.  Successfully hooked module.
DllMain(0x10220000, DLL_PROCESS_ATTACH, 0x00000000) in "TK84.DLL" called.
DllMain(0x10220000, DLL_PROCESS_ATTACH, 0x00000000) in "TK84.DLL" returned 1 (0x1).
DllMain(0x018A0000, DLL_PROCESS_ATTACH, 0x00000000) in "TCL84.DLL" called.
DllMain(0x018A0000, DLL_PROCESS_ATTACH, 0x00000000) in "TCL84.DLL" returned 1 (0x1).
DllMain(0x01890000, DLL_PROCESS_ATTACH, 0x00000000) in "_TKINTER.PYD" called.
DllMain(0x01890000, DLL_PROCESS_ATTACH, 0x00000000) in "_TKINTER.PYD" returned 1 (0x1).
LoadLibraryExA("C:\python24\DLLs\_tkinter.pyd", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned 0x01890000.
GetProcAddress(0x01890000 [_TKINTER.PYD], "init_tkinter") called from "PYTHON24.DLL" at address 0x1E054899 and returned 0x01894EB0.
LoadLibraryA("kernel32") called from "TCL84.DLL" at address 0x018FE872.
LoadLibraryA("kernel32") returned 0x7C800000.
GetProcAddress(0x7C800000 [KERNEL32.DLL], "GetFileAttributesExW") called from "TCL84.DLL" at address 0x018FE88A and returned 0x7C81130D.
GetProcAddress(0x7C800000 [KERNEL32.DLL], "CreateHardLinkW") called from "TCL84.DLL" at address 0x018FE89B and returned 0x7C86B0DC.
GetProcAddress(0x7C800000 [KERNEL32.DLL], "FindFirstFileExW") called from "TCL84.DLL" at address 0x018FE8AC and returned 0x7C80EC7D.
GetProcAddress(0x7C800000 [KERNEL32.DLL], "GetVolumeNameForVolumeMountPointW")
called from "TCL84.DLL" at address 0x018FE922 and returned 0x7C823A71.

Following is the trace for "root = Tix.Tk()"

LoadLibraryW("C:/Python24/tcl/reg1.1/tclreg11.dll") called from "TCL84.DLL" at address 0x019060B1.
Loaded "TCLREG11.DLL" at address 0x10210000.  Successfully hooked module.
DllMain(0x10210000, DLL_PROCESS_ATTACH, 0x00000000) in "TCLREG11.DLL" called.
DllMain(0x10210000, DLL_PROCESS_ATTACH, 0x00000000) in "TCLREG11.DLL" returned 1 (0x1).
LoadLibraryW("C:/Python24/tcl/reg1.1/tclreg11.dll") returned 0x10210000.
GetProcAddress(0x10210000 [TCLREG11.DLL], "Registry_Init") called from "TCL84.DLL" at address 0x01906021 and returned 0x10212910.
***** GetProcAddress(0x10210000 [TCLREG11.DLL], "Registry_SafeInit") called from "TCL84.DLL" at address 0x01906021 and returned NULL. Error: The specified procedure could not be found (127).
***** GetProcAddress(0x10210000 [TCLREG11.DLL], "_Registry_SafeInit") called from "TCL84.DLL" at address 0x01906054 and returned NULL. Error: The specified procedure could not be found (127).
LoadLibraryW("C:/Python24/tcl/tix8.1/tix8183.dll") called from "TCL84.DLL" at address 0x019060B1.
Loaded "TIX8183.DLL" at address 0x01930000.  Successfully hooked module.
Unloaded "TIX8183.DLL" at address 0x01930000.
***** LoadLibraryW("C:/Python24/tcl/tix8.1/tix8183.dll") returned NULL. Error: The specified module could not be found (126).
LoadLibraryW("C:/python24/tcl/tix8.1/tix8183.dll") called from "TCL84.DLL" at address 0x019060D7.
Loaded "TIX8183.DLL" at address 0x01930000.  Successfully hooked module.
Unloaded "TIX8183.DLL" at address 0x01930000.
***** LoadLibraryW("C:/python24/tcl/tix8.1/tix8183.dll") returned NULL. Error: The specified module could not be found (126).

Note that it successfully loads TIX8183.DLL before deciding it cannot find it...
Also, I tried to profile IDEStudio (the Tix program that worked) - it's a lot to go through, and it also pre-loads Tix, so it's hard to spot where it is succeeding.  I'll post again if I find anything.
0
 
sburckAuthor Commented:
I installed the entire setup on another PC, the problem disappeared.  I'll give the points to RichieHindie for the pointers.
0
 
RichieHindleCommented:
Thanks, sburck!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now