Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Win32api problems

1,141 views
Skip to first unread message

GerritM

unread,
Oct 22, 2019, 5:23:20 AM10/22/19
to
I recently installed IPython, Pandas, Altair, Jupyter, MatPlotLib, and Numpy on my Windows 10, Python27 installation to explore what it can do.

When I tried to run my normal scripts a few days later, I discovered that win32com and related modules like win32ami give problems:

Traceback (most recent call last):
  File "D:\gaudi\src\PythonTools\generateDocumentsPdf.py", line 10, in <module>
    from win32com.client.dynamic import Dispatch
  File "C:\Python27\lib\site-packages\win32com\__init__.py", line 5, in <module>
    import win32api, sys, os
ImportError: DLL load failed: The specified procedure could not be found.

after trying out several tips on Internet, like copying dll and pyd files, I re-installed my entire ActiveState installation. Luckily it works again.

However, question is what culprit of my initial list damaged the Python-win32 configuration?

Gerrit

Terry Reedy

unread,
Oct 22, 2019, 6:09:46 AM10/22/19
to
On 10/22/2019 5:23 AM, GerritM wrote:
> I recently installed IPython, Pandas, Altair, Jupyter, MatPlotLib, and Numpy on my Windows 10, Python27 installation to explore what it can do.

All of those 5 packages either have or will stop supporting 2.x. See
https://python3statement.org/.

> When I tried to run my normal scripts a few days later, I discovered that win32com and related modules like win32ami give problems:
>
> Traceback (most recent call last):
>   File "D:\gaudi\src\PythonTools\generateDocumentsPdf.py", line 10, in <module>
>     from win32com.client.dynamic import Dispatch
>   File "C:\Python27\lib\site-packages\win32com\__init__.py", line 5, in <module>
>     import win32api, sys, os
> ImportError: DLL load failed: The specified procedure could not be found.
>
> after trying out several tips on Internet, like copying dll and pyd files, I re-installed my entire ActiveState installation. Luckily it works again.
>
> However, question is what culprit of my initial list damaged the Python-win32 configuration?

Install 1 at a time and try your normal scripts? Or try them with 3.7.

--
Terry Jan Reedy


moi

unread,
Oct 22, 2019, 11:22:35 AM10/22/19
to
Le mardi 22 octobre 2019 12:09:46 UTC+2, Terry Reedy a écrit :
>
> All of those 5 packages either have or will stop supporting 2.x. See
> https://python3statement.org/.
>

And how many of these "products" are really working
correctly?

Certainly not Qt5 derivatives.

GerritM

unread,
Oct 22, 2019, 11:43:10 AM10/22/19
to
On Tuesday, October 22, 2019 at 12:09:46 PM UTC+2, Terry Reedy wrote:
> On 10/22/2019 5:23 AM, GerritM wrote:
<...snip...>
>
> Install 1 at a time and try your normal scripts? Or try them with 3.7.
>
> --
> Terry Jan Reedy

I am working on the Python 2 to Python 3 transition.

I found on Internet many people struggling with Win32 over the years. It served me without problems for decades. So, I was wondering, whether somewhere in the growth of modules and options a weak spot is appearing...

Gerrit

Albert-Jan Roskam

unread,
Oct 22, 2019, 12:31:21 PM10/22/19
to


On 22 Oct 2019 11:23, GerritM <gerrit...@gmail.com> wrote:

> ImportError: DLL load failed: The specified > procedure could not be found.

I've had the same error before and I solved it by adding the location where the win32 dlls live to PATH. Maybe PATH gets messed up during the installation of something.

Terry Reedy

unread,
Oct 22, 2019, 1:25:19 PM10/22/19
to
On 10/22/2019 11:42 AM, GerritM wrote:
> On Tuesday, October 22, 2019 at 12:09:46 PM UTC+2, Terry Reedy wrote:
>> On 10/22/2019 5:23 AM, GerritM wrote:
> <...snip...>
>>
>> Install 1 at a time and try your normal scripts?

Starting from a state of ignorance about interactions between Win32 and
other modules, this is what I would do.
> I found on Internet many people struggling with Win32 over the years. It served me without problems for decades. So, I was wondering, whether somewhere in the growth of modules and options a weak spot is appearing...

Is there a win32 list where people might have more knowledge of such?

--
Terry Jan Reedy

MRAB

unread,
Oct 22, 2019, 2:02:36 PM10/22/19
to
I recently had a problem when I tried win32 on a newly-installed Python
3.8 and I couldn't import win32clipboard. The solution in that case was
to copy pywintypes38.dll and pythoncom38.dll from
site-packages/pywin32_system32 into site-packages/win32. (Note: those
names had "38" for Python 3.8.)

Sibylle Koczian

unread,
Oct 22, 2019, 2:10:04 PM10/22/19
to
Am 22.10.2019 um 19:24 schrieb Terry Reedy:
>
...
> Is there a win32 list where people might have more knowledge of such?
>
There is:

python...@python.org
https://mail.python.org/mailman/listinfo/python-win32

If you prefer Gmane:

news://news.gmane.org/gmane.comp.python.windows

HTH



Sibylle Koczian

unread,
Oct 22, 2019, 2:16:03 PM10/22/19
to

Eryk Sun

unread,
Oct 22, 2019, 2:26:07 PM10/22/19
to
On 10/22/19, Albert-Jan Roskam <sjeik...@hotmail.com> wrote:
> On 22 Oct 2019 11:23, GerritM <gerrit...@gmail.com> wrote:
>
>> ImportError: DLL load failed: The specified > procedure could not be
>> found.

Many of the PyWin32 extensions depend on pywintypesXX.dll, and some
depend on pythoncomXX.dll. There's a post-installation script that
copies them either to the System32 directory or to Python's
installation directory (i.e. the location of python.exe). The latter
is better if you're doing this manually. There's no reason to pollute
System32.

If you're developing a service, pythonerservice.exe depends on
pythonXX.dll, so copy pythonservice.exe to Python's installation
directory as well if pythonXX.dll is located there instead of in
System32.

You can use relative symlinks instead of copies if Python is installed
on a file system that supports reparse points, such as the system
volume (NTFS). For example:

>>> print(os.readlink(os.path.join(sys.prefix, 'pywintypes37.dll')))
Lib\site-packages\pywin32_system32\pywintypes37.dll

Then if you upgrade PyWin32, you won't have to remember to replace the
old copies.

> I've had the same error before and I solved it by adding the location where
> the win32 dlls live to PATH. Maybe PATH gets messed up during the
> installation of something.

In Python 3.8, PATH isn't used when loading extension modules. It's
also not used when loading DLLs via ctypes. In many cases this change
isn't an issue since dependendent DLLs are in the same directory as
the extension module. If not, add the directory that has the
dependencies via os.add_dll_directory().
0 new messages