ModuleNotFoundError after `pip install --target=path/to/folder pywin32`
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)
+1
+1
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.
+1
I ran into a very similar problem here:
Does not build correctly when --target is selected