pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

ModuleNotFoundError after `pip install --target=path/to/folder pywin32`

Open gschoissengeyr opened this issue 5 years ago • 2 comments

When installing pywin32 with python -m pip install --target=path/to/site pywin32-227-cp37m-win_amd64.whl I get this error:

>>> import win32api
Traceback (most recent call last):  
  File  "<stdin>", line 1, in <module>  
ModuleNotFoundError: No module named 'win32api'

I verified that path/to/site is inside sys.path (defined in PYTHONPATH), this for example doesn't produce an error: >>> import win32. The installation is conducted without administrator rights to the python installation folder or to system32, etc., I don't think this is the problem because it works fine when installing in %APPDATA% with python -m pip install --user pywin32-227-cp37m-win_amd64.whl I tried the solutions described in #1399 , without success. This was also tested with versions 223, 224 and 225 with the same outcome.

System: python 3.7.4 (tags/v3.7.4:e09359112e) [MSC v.1916 64 bit (AMD64)] on win32 Microsoft Windows Version 1803 (Build 17134.1304)

gschoissengeyr avatar Mar 12 '20 14:03 gschoissengeyr

+1

xihajun avatar Sep 21 '21 14:09 xihajun

+1

sontakke12297 avatar Aug 24 '22 10:08 sontakke12297

I verified that path/to/site is inside sys.path (defined in PYTHONPATH), this for example doesn't produce an error: >>> import win32.

It is not enough to add this custom sitedir "manually" to sys.path? Does it solve the issue, when you use site.addsitedir(sitedir) so that the .pth files in there are processed - which adds more dirs to the sys.path and ensures the pywintypesNN.dll is found ?

fine when installing in %APPDATA% with python -m pip install --user pywin32...

This uses the site.getusersitepackages() dir - which is auto-addsitedir()'ed by Python startup.

I tried the solutions described in #1399

This is a different problem - when pywintypesNN.dll is not found by win32api.pyd etc, or outdated copies are found 1st on the PATH.

kxrob avatar Dec 03 '22 14:12 kxrob

+1

I ran into a very similar problem here: image

Does not build correctly when --target is selected

OrionSehn avatar Dec 12 '23 06:12 OrionSehn