Search code examples
pythonpywin32

Can't get pywin32-219 to work with python 3.5


It seems to install without error using the EXE (in my case pywin32-219.win-amd64-py3.5.exe) however when run the python interpreter and try to "import win32api" I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.

If I download the zip file and try to run "setup3.py install" I get the following output:

Converting...
Executing...
Building pywin32 3.5.219.0
Traceback (most recent call last):
  File "setup3.py", line 16, in <module>
    exec(str(got))
  File "<string>", line 1929, in <module>
  File "<string>", line 587, in __init__
  File "C:\Python35\lib\ntpath.py", line 113, in join
    genericpath._check_arg_types('join', path, *paths)
  File "C:\Python35\lib\genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'

I've tried a couple of things but cant get it to work.

Has anyone gotten pywin32 to install and work correctly with python 3.5?


Solution

  • The compiling from source error is related to pywin32 not catching an error that ends up crashing everything. Specifically line 587 of setup.py causes a crash if sdk_dir is None.

    Changing line 587 to

    if sdk_dir and os.path.isfile(os.path.join(sdk_dir, "include", "activdbg.h")):
    

    prevents that crash, but my installation later crashes with the following error:

    win32/src/win32wnet/PyNetresource.cpp(120): error C2440: 'initializing': 
    cannot convert from 'int (__cdecl *)(PyObject *,PyObject *)' to 'PyAsyncMethods *'win32/src/win32wnet/PyNetresource.cpp(120): note: There is no context in which this conversion is possible
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2