I'm trying to use win32gui from pywin32 but I keep getting this error:
ModuleNotFoundError: No module named 'win32gui'
I am on windows 10, python 3.9
I have been researching the top results on stack over flow and google for a while now and the solutions i found don't work for me.
things I have tried:
installed pywin32 via a whl file (this shows in site packages along with win32 ect)
double checked both 64bit versions of python and pywin32 are installed
Added pywin32 to Path (worth a try)
tried "from win32 import win32gui"
Any help would be appreciated!
Requested commands with output:
importing win32api and win32com results in the same out of
ModuleNotFoundError: No module named 'win32api'
ModuleNotFoundError: No module named 'win32com'
python -m pip install pywin32
Requirement already satisfied: pywin32 in c:\users\user\appdata\local\programs\python\python39\lib\site-packages (304.0)
python -c "import win32gui" -- nothing happens when i run this line in a cmd (maybe i have done something wrong here?)
Solution unknown however it was fixed by simply recreating the virtual environment and installing the pywin32.
Related
When I tried to import xlwings using import xlwings as xw, it shows the following error:
from win32.api import *
ModuleNotFoundError: No module named 'win32.api'
My environment is:
Windows 10
Python 3.10
IDE: PyCharm
Does anyone know how to fix it?
You probably don't have the pywin32 module installed.
Try pip install pywin32 and check this question
Code:
from pycoin.ecdsa.secp256k1 import secp256k1_generator
When I run this, I get the error:
ModuleNotFoundError: No module named 'pycoin'
I've tried doing:
pip3 install pycoin
aswell as
pip install pycoin
Both of which have lead to the same error.
I've ran the code on python and python3 which also leads to the same error.
Any solutions?
Go to terminal or cmd on windows and type python3 (python2, python for older versions)
Then try to import the module there.
If the module in imported successfully then reopen your IDE. and then try.
When I run my code that includes psutil module I encounter the following error:
Traceback (most recent call last):
File "/Users/alek/Desktop/coloring/solver.py", line 4, in <module>
from psutil import cpu_count
ModuleNotFoundError: No module named 'psutil'
Although, when trying to install the module in terminal, I can see the following
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: psutil in /opt/homebrew/lib/python3.9/site-packages (5.9.1)
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
WARNING: There was an error checking the latest version of pip.
How should I ensure that the module is in the right environment and can be used by my program?
Thanks in advance!
try to upgrade it
sudo pip install --upgrade psutil
try to run this command in python shell:
import site
site.getsitepackages()
actually, it is trying to search psutil module in one of the Xcode path.
see if you have psutil in this path:
/Applications/Xcode_13.4.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages
if not add the psutil module here and it should work.
it worked for me.
when I try to run my python programme in Kali Linux I get this error:
python myprogramme.py
ImportError: no module named configobj
so I installed this using these methods
sudo apt install python3-configobj
pip install configobj
both installed successfully however I'm still getting this same error and I wondered if there were any other factors that might be causing the error
thank you
I was trying to use the playsound function from the playsound module in Python 3. I obtained an mp3 file of a fire alarm sound from http://soundbible.com/1656-House-Fire-Alarm.html to test and saved as siren1.mp3.
Minimal code:
from playsound import playsound
playsound('siren1.mp3')
Initially, I tried to run the minimal, 2 line Python code in Thonny and could not get it to work, as it gave "No module named gi" error.
It led me to try various things, finding that some of them worked and others did not. Because I eventually managed to get playsound to work in Thonny, my question is not how to get playsound working.
On Stack Overflow I find many related or similar questions of the form "x works on y but not on z" and "No module named xx" error. As a relatively new Python user, what I am looking for is guidance on how to understand the different paths taken by Python to look for modules etc. depending on how one executes Python code.
Here are the experiments I did and my observations:
When I ran the minimal code in Thonny (Thonny version 2.1.16, Python version 3.6.7, Tk version 8.6.8), it failed with "No module named gi" error.
The same Python program worked correctly when I ran it in IDLE (IDLE version 3.6.7, Python version 3.6.7, Tk version 8.6.8) and siren noise was played.
In Ubuntu (18.04) terminal, $ which python showed:
/usr/bin/python
$ python3 ./playSiren.py
ran correctly and produced sound
Now executed python3 at the command prompt
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on Linux
Now I copied and pasted the two Python code lines and ran them
on the Python prompt.
Again the code ran correctly and produced sound.
I added a shebang line to the minimal code and changed it to an executable and then ran it from the Ubuntu prompt.
Again the code ran correctly and produced sound
When I ran: sudo apt-get install python3-gi,
I get the message:
python3-gi is already the newest version (3.26.1-2ubuntu1).
In IDLE:
>>> import gi
>>> gi
<module 'gi' from '/usr/lib/python3/dist-packages/gi/__init__.py'>
sys.path in IDLE:
/home/pi/.local/lib/python3.6/site-packages
/home/pi/Python Learning
/usr/bin
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/usr/lib/python3/dist-packages
/usr/lib/python36.zip
/usr/local/lib/python3.6/dist-packages
In Thonny:
>>> import gi
Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
ModuleNotFoundError: No module named 'gi'
sys.path in Thonny:
/home/pi/.thonny/Python36/lib/python3.6/site-packages
/home/pi/.thonny/jedi_0.11.1
/home/pi/Python Learning
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/usr/lib/python3/dist-packages/thonny/shared
/usr/lib/python36.zip
On Thonny I appended the following to the sys.path:
sys.path.append('/usr/lib/python3/dist-packages/gi/__init__.py')
sys.path.append('/usr/lib/python3/dist-packages/gi/')
Still, I was getting No module named 'gi' error on Thonny.
If IDLE shows gi module to be in /usr/lib/python3/dist-packages/gi/__init__.py, I expected Thonny also to be able to find gi when I appended this to the sys.path. Why did it not work?
Then I appended the following:
sys.path.append("/usr/lib/python3/dist-packages")
Now, there was no "No module named 'gi'" error anymore and
play sound correctly produced the siren sound!
I assume you have installed Thonny+Python bundle from Thonny's homepage. In this case Thonny uses its own separate Python interpreter, which has its own packages.
Tweaking sys.path to include another interpreter's packages, is not reliable. It may work for Python-only packages, but it definitely won't work if the other interpreter is of different (eg. 3.6 vs 3.7) and the package is (partially) implemented in C.
You should either install all required packages for Thonny's Python ("Tools => Manage packages" would install them per-user, which means they are shared among all interpreters of same version) or you make Thonny use your system interpreter for running the programs (Tools => Options => Interpreter). I recommend the latter.
from the official link, for ubuntu/debian users
Execute sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 to install the build dependencies and GTK
Execute pip3 install pycairo to build and install Pycairo
Execute pip3 install PyGObject to build and install PyGObject