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

Unable work in vene #56

Open
ss8688 opened this issue Sep 14, 2024 · 5 comments
Open

Unable work in vene #56

ss8688 opened this issue Sep 14, 2024 · 5 comments

Comments

@ss8688
Copy link

ss8688 commented Sep 14, 2024

Already installed pygetwindow in venv

Requirement already satisfied: pygetwindow in d:\git\warthunder_yellow_mark_rangefinder\distance\venv\lib\site-packages (0.0.9)
Requirement already satisfied: pyrect in d:\git\warthunder_yellow_mark_rangefinder\distance\venv\lib\site-packages (from pygetwindow) (0.2.0)

But Python reported such an error

Traceback (most recent call last):
  File "D:\git\WarThunder_Yellow_Mark_Rangefinder\distance\code\printResults.py", line 7, in <module>
    import pygetwindow as gw
ModuleNotFoundError: No module named 'pygetwindow'

If it doesn't run in Venv, there won't be any problem

@ss8688
Copy link
Author

ss8688 commented Sep 14, 2024

Is this normal?

@AshhadDevLab
Copy link

This is caused by wrong Python interpreter version selected. Lets say you have made a virtual environment of Python and install PyGetWindow or any other library/package but forgot to later on change the interpreter the terminal is running then the Python file that is being executed will not run according to that virtual environment.

You can simply run this command to see the path of the interpreter your terminal is running:

Get-Command python

@ss8688
Copy link
Author

ss8688 commented Oct 6, 2024

This is caused by wrong Python interpreter version selected. Lets say you have made a virtual environment of Python and install PyGetWindow or any other library/package but forgot to later on change the interpreter the terminal is running then the Python file that is being executed will not run according to that virtual environment.

You can simply run this command to see the path of the interpreter your terminal is running:

Get-Command python
(venv) D:\git\WarThunder_Yellow_Mark_Rangefinder\distance>where python
D:\git\WarThunder_Yellow_Mark_Rangefinder\distance\venv\Scripts\python.exe
C:\Program Files\Python312\python.exe
C:\Users\shiqi\AppData\Local\Microsoft\WindowsApps\python.exe

It's not like that. I didn't forget to run activate.bat to start venv, and besides pygetwindow, all other packs are running normally

@AshhadDevLab
Copy link

Hmm, give me a moment to examine this in detail

@AshhadDevLab
Copy link

AshhadDevLab commented Oct 6, 2024

(venv) D:\git\WarThunder_Yellow_Mark_Rangefinder\distance>where python
D:\git\WarThunder_Yellow_Mark_Rangefinder\distance\venv\Scripts\python.exe
C:\Program Files\Python312\python.exe
C:\Users\shiqi\AppData\Local\Microsoft\WindowsApps\python.exe

There are multiple factors causing this if its not the above, first either the terminal you are using isn't using the virtual environment or either isn't configured right.

Second depends on what IDE you are using, if you are using Visual Studio Code then I will suggest you to once change the virtual environment using the Python: Select Interpreter command. After selecting the venv from there kill your current working terminal and recreate a new terminal and also reinstall pygetwindow.

Another solution you can try is try running this command in the terminal:

python

which will open the terminal integrated python shell, then you can run this command:

import sys
print(sys.executable)

this will show you the path to the interpreter you are using, just to let you know the issue isn't regarding pygetwindow, sometime malfunctioned installation of the package or many other reasons cause this type of issue

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

2 participants