Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pywin32

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?

like image 377
Cyberclops Avatar asked Oct 03 '15 08:10

Cyberclops


2 Answers

You need to run the pywin installer with elevated permissions as it writes to the system32 folder. If you didn't run with elevated permissions, open an admin cmd prompt and run the postinstall script in the pywin install directory.

like image 150
Dinos Avatar answered Oct 08 '22 19:10

Dinos


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 
like image 20
Ric Avatar answered Oct 08 '22 19:10

Ric