Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gschoissengeyr opened this issue Mar 12, 2020 · 4 comments
Open

Comments

@gschoissengeyr
Copy link

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)

@xihajun
Copy link

xihajun commented Sep 21, 2021

+1

@sontakke12297
Copy link

+1

@kxrob
Copy link
Collaborator

kxrob commented Dec 3, 2022

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.

@OrionSehn
Copy link

+1

I ran into a very similar problem here:
image

Does not build correctly when --target is selected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants