I am not able to import pywhatkit in repl.it - python

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.

Related

Using the keyboard module in Python 3.8 on Mac

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?

Using the keyboard module in Python 3.8 on my Mac

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?

Asking for overwrite while trying to run script in ipython

I am fairly new to programming in python. I installed anaconda and am running iPython (the Jupyter qtconsole) v.4.3.0 and python v.3.6 on a Mac. Currently, I am trying to import a module with functions located in my home directory.
I have looked at stackoverflow and python documentation and found that it could be done with:
%run "Users/myUser/python_functions.py"
or
import python_functions
However, when I try both of these approaches, I get prompted to overwrite the file that I am running or importing:
File `python_functions.py` exists. Overwrite (y/[N])?
This is changing the previous file and not getting the functions I want to be imported.
What may explain this, and what can I do to import my module?
this is wrong but leaving it up for shame
import on ubuntu (and I'm guessing many other unix-like OSs including Mac) is a utility that saves any visible window on an X server and outputs it as an image file. You can capture a single window, the entire screen, or any rectangular portion of the screen.
My guess if you are running the import command in your console, and it's about to take a screenshot and save it over an existing file - python_functions
Before you the use the python import command, start a python interpreter:
$ python
>>>import yourfile
edit: on re-reading your question, I'm not so sure about my guess anymore, but leaving it up until you tell me I'm wrong :)
Running Jupyter qtconsole as an interpreter is likely causing the problem in this scenario. Instead using a IDE or command line interpreter will resolve it .
Since anaconda was installed, trying it with the IDE Spyder executes the code just fine without the overwrite prompt. It works on others (e.g PyCharm, Rodeo, etc.) as well.

Strange error with Keras and Spyder

I'm using Spyder to do some small projects with Keras, and every now and then (I haven't pinned down what it is in the code that makes it appear) I get this message:
File "~/.local/lib/python3.5/site-packages/google/protobuf/descriptor_pb2.py", line 1771, in <module>
__module__ = 'google.protobuf.descriptor_pb2'
TypeError: A Message class can only inherit from Message
Weirdly, this exception is not raised if I execute the program outside of Spyder, using the terminal. I've looked around and I have found no one who has encountered this error while using Keras.
Restarting Spyder makes it go away, but it's frustrating. What could be causing it?
I had the same problem with Spyder, which happened when it was trying to reload modules that were already loaded. I solved it by disabling the UMR (User Module Reloader) option in "preferences -> python interpreter" .
Ok, I found the cause: interrupting the execution before Keras fully loads.
As said before restarting Spyder (or just the console) solves it.
Restarting Sypder works or run your script using console only.
Don't forget to use at the top:
from google.cloud import bigquery
from google.oauth2 import service_account
from google.auth.transport import requests

Python Modules Appear to not be Installing Correctly

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.

Categories

Resources