I am trying to write a code that allows me to make a keyboard press to trigger an output. I am trying to use the keyboard module to do this, but every time I try to run it I get an error that says:
File "/Users/julietdenapoli/Desktop/keyboard.py", line 10, in from msvcrt import getch ModuleNotFoundError: No module named 'msvcrt'
I kept noticing that the issue was coming from the import keyboard, so I literally just tried to run a one line code:
import keyboard
And I still get that same error. I did pip install keyboard, not really sure why I am running into this error?
Related
I was making a program using pywhatkit to send WhatsApp messages. However, when trying to import pywhatkit, the following exception is raised:
(Sorry, I was not able to copy the error message.)
Can anyone tell me why this is happening?
One of the dependencies of pywhatkit is the pyautogui module (see here for what pyautogui is). REPL.it runs on Linux, a Unix-like OS; on Unix, pyautogui requires Xlib (hence, Xlib.error.XauthError). On importing pywhatkit, Xlib attempted to open the .Xauthority file, but failed to do so, in this case because the file does not exist. I believe this behavior has to do with REPL.it itself, i.e., there's nothing you can do about it.
For background on what the .Xauthority file is, refer to this AskUbuntu question.
My main script is in (local-directory)/desktop/code and I'm trying to import a Python script from the same folder by running:
import gui.pyw
The GUI loads when I execute the main script but the main script doesn't.
When I close the GUI, it gives me the error:
ModuleNotFoundError: No module named 'gui.pyw'; 'gui' is not a package
I don't know why it's not finding it. any help is appreciated :)
Maybe be you should just write import gui. When you are writing import gui.pyw, it is assuming pyw as a function in the gui script instead of importing/running the whole script.
I am trying to write a code that allows me to make a keyboard press to trigger an output. I am trying to use the keyboard module to do this, but every time I try to run it I get an error that says:
File "/Users/julietdenapoli/Desktop/keyboard.py", line 10, in
from msvcrt import getch ModuleNotFoundError: No module named 'msvcrt'
I kept noticing that the issue was coming from the import keyboard, so I literally just tried to run a one line code:
import keyboard
And I still get that same error. I did pip install keyboard, not really sure why I am running into this error?
I've tried installing PyGame and it just crashes with the window closing too fast to see the error when I import it. I've tried every package, using the installer or wheel file, but none have worked.
The code I have so far is thus:
import pygame
input()
The program does not wait for a key press and still just closes at execution.
I am aware there are similar questions already, but none of those solutions have seemed to work.
The issue is not with installation. If there is nothing in your program, the program will just open and close really quickly.
You can test out your pygame module this way.
On Windows, open up the Python command line interpreter. Run:
>>> import pygame
>>>
You should see just a blank >>> if it loaded correctly.
Same for Linux and OS X, but just type python in a terminal to run the interpreter.
If it gives an error, comment the error below and we can go from there.
running linux mint 13
idle-python3.2 did work from the terminal before, now it does not.
Calling idle-python3.2 from the terminal throws the error below BUT I can run Idle by double clicking on the script!
Here's the very simple script that broke it all(?)
http://pastebin.com/pP9An3UU
FWIW, the script does not appear to work either (nothing happens when I run it).
Here's the error in the terminal when trying to run Idle3.2 from the terminal:
File "tkinter.py", line 2, in <module>
tk = Tk()
NameError: name 'Tk' is not defined
here's the full error
http://pastebin.com/J5AfAQyV
I know tkinter is not installed by default... but it IS installed
python3-tk is already the newest version.
python3-tk set to manually installed.
I've checked the system monitor and killed all obvious python instances running in the background.
But, still no joy.
Here's a video of the error:
http://youtu.be/oCLOJR2rktI
Your help for a fix is appreciated.
It sounds like you either a) named your little test program "tkinter.py", or b) you have another file in the same directory named "tkinter.py". If that is the case, when you do from tkinter import *, you are not importing the real tkinter but rather importing the local file.
If you named your file "tkinter.py", rename it. Also, if there is a file named "tkinter.pyc", remove it.