[python-win32] suggested change to pywintypes.py for non-admininstall

Trent Mick trentm at activestate.com
Fri Mar 9 18:28:57 CET 2007


Mark Hammond wrote:
>> Mark and others,
>>
>> For a non-admin install pywintypesXY.dll and pythoncomXY.dll
>> cannot be put in
>> the system directory. The typical alternative is to put them
>> in the install
>> dir, next to python.exe. "pywintypes.py" is setup to know how
>> to find it when
>> doing either of:
>>
>>      import pywintypes
>>      import pythoncom
>>
>> However, doing any of (and similar):
>>
>>      import win32api
>>      from win32com.shell import shell
>>
>> fails. You have to do one of the former first.
> 
> Yeah - that sucks.  I actually wasn't aware it did it for a normal Python
> non-admin install (although if I thought more about when I had seen it, I
> should have worked it out!)
> 
>> If however we put the system DLLs next to win32api.pyd et al
>> (and update
>> pywintypes.py to look there) then those imports work. The
>> win32comext imports
>> seems to work too because "win32api" will have been imported by then.
> 
> That sounds OK I guess - not actually *good*, but sounds like it will be an
> improvement (and I can't see the "good" answer).  It will not help someone
> who does 'import customwin32' (ie, their own module linked against
> pywintypes), but OTOH, the change would not make it *more* broken for them
> than it already is.

Now I'm not sure. I've tried this (in an ActivePython build) and having 
pywintypes25.dll and pythoncom25.dll next to win32api.pyd causes Pythonwin.exe 
startup to fail because a simple:
	import win32ui
fails with the system DLLs is *either* location unless you do:
(a) "import pythoncom" (or any of the others that work) first; and/or
(b) put the dir with the system DLLs on your PATH:

> C:\>C:\Python25\python.exe -c "import win32ui"
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> ImportError: DLL load failed: The specified module could not be found.
> 
> C:\>set PATH=C:\Python25;%PATH%
> 
> C:\>C:\Python25\python.exe -c "import win32ui"


So... I'm not longer sure my suggestion is a good one. If the system DLLs are 
left in the install dir then telling the user to "put the Python install dir 
on your PATH" would be a sufficient solution to getting *all* the PyWin32 
imports to just work.

Given that my suggestion is no panacea, perhaps it is better to just leave it 
at status quo and tell the user about the requirement to update their PATH.

Thoughts?

Trent

-- 
Trent Mick
trentm at activestate.com


More information about the Python-win32 mailing list