First off thanks for taking the time to read this:
I am currently trying to get ToastNotifier working in python in MU.
I have imported ToastNotifier from win10toast as such :
from win10toast import ToastNotifier
I have the created this function:
def notifacation():
toast = ToastNotifier()
Title = "Notifacation"
message = "Hello from Ben Colledge"
icon = "a.ico"
length = 30
toast.show_toast(title, message, icon_path=icon, duration=length)
And then called the function like so :
notifacation()
I then run the code and it give me this error message
Traceback (most recent call last):
File "c:\users\puzzl\mu_code\notifacation.py", line 1, in module
from win10toast import ToastNotifier
ModuleNotFoundError: No module named 'win10toast'
I have then gone to https://pypi.org/project/win10toast/ and downloaded win10toast yet nothing happened
Any help would be appreciated
Thanks
I had the exact same problem but then I figured out this works best
python.exe -m pip install win10toast
I ran this code and it still has a problem not, although, the same one. Now the bug would be that in the line that has the method.
toast.show_toast(title, message, icon_path=icon, duration=length)
The problem is that 'title' is undefined. The variable that you assigned was named 'Title'. Since Python is case-sensitive, 'title' is an undifined variable. this is what the line should look like now:
toast.show_toast(Title, message, icon_path=icon, duration=length)
Yay! It works now!
Related
I'm running into an issue with my moviepy install but I can't figure out where it is going wrong. I have tried pip install moviepy and it says all the requirements are satisfied, but in my editor when I try "from moviepy.editor import *" moviepy is underlined and says ""moviepy": Unknown word." I have tried running pip uninstall moviepy and reinstalling it but that hasn't worked. I'm using selenium in the same project and it works fine which is why I'm confused but if anyone has an idea of what to do I would really appreciate it.
Here is the code if needed, and if you want me to try running something let me know.
main.py
from get_clips import get_clips
from download_clips import download_clips
from upload_clips import upload_clips
from edit_clips import edit_clips
if __name__ == "__main__":
clips = get_clips()
download_clips(clips)
edit_clips(clips)
#upload_clips(clips)
print('done')
edit_clips.py
from moviepy.editor import *
def edit_clips(clips):
for clip in clips:
video = moviepy.editor.VideoFileClip('D:/zgarw/Documents/Projects/autoclip/tmp/' + clip['slug'] + '.mp4')
video_duration = int(video.duration)
print(video_duration)
This is the error I'm getting when I run the code.
Traceback (most recent call last):
File "c:\Users\zgarw\Documents\Projects\autoclip\main.py", line 9, in <module>
edit_clips(clips)
File "c:\Users\zgarw\Documents\Projects\autoclip\edit_clips.py", line 6, in edit_clips
video = moviepy.editor.VideoFileClip('D:/zgarw/Documents/Projects/autoclip/tmp/' + clip['slug'] + '.mp4')
NameError: name 'moviepy' is not defined
You're getting the error because you haven't imported the name moviepy into the current namespace. Instead, you imported all the public members of moviepy.editor. Change your code to
video = VideoFileClip('D:/zgarw/Documents/Projects/autoclip/tmp/' + clip['slug'] + '.mp4')
and it should run fine. If you want to access other modules of moviepy or use your original code, simply do import moviepy.
If you are only using VideoFileClip then you can edit edit_clips.py as :
from moviepy.editor import VideoFileClip
def edit_clips(clips):
for clip in clips:
video = VideoFileClip('D:/zgarw/Documents/Projects/autoclip/tmp/' + clip['slug'] + '.mp4')
video_duration = int(video.duration)
print(video_duration)
Since using in general import statement as
from module import *
will pollute namespace and is a bad habit.
I'm new to python and I'm having this problem that I can't figure it out.
My file structure is:
enter image description here
On Criador.py I have several functions, for example:
def doSomething():
pass
def doSomethingElse():
pass
and Im trying to use one of this functions on the Controller.py file:
The first thing I did was, on the Controller.py:
import Controller.Criador
and then tried to use that function as:
Controller.Criador.doSomething()
After running Controller.py, I got this error:
ModuleNotFoundError: No module named 'Controller.Criador'; 'Controller' is not a package
I tried several other things, like:
from . import Criador
or
from Controller.Criador import doSomething
or
from Controller import Criador
and nothing helped, just changed the errors to:
ImportError: cannot import name 'Criador'
and
ModuleNotFoundError: No module named 'Controller.Criador'; 'Controller' is not a package
and
ImportError: cannot import name 'Criador'
Can someone give me a light about this? I'm using PyCharm and it does not give me any error when I declare the imports, only when I run the file
If Controller.py and Criador.py are in the same folder, you can do this inside Controller.py:
import Criador
Criador.doSomething()
This is my code:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items
message = messages.GetLast()
body_content = message.body
print (body_content)
and I am getting the following error:
C:\Users\bre\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/bre/PycharmProjects/test/TkinterApp/test13.py
Traceback (most recent call last):
File "C:/Users/bre/PycharmProjects/test/TkinterApp/test13.py", line 1, in <module>
import win32com.client
File "C:\Users\bre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found.
Process finished with exit code 1
What exactly does this mean, and how would I be able to fix it? I saw that I can download some DLL, but I don't have experience dealing with that. Any suggestions or step-by-step recommendation on how to make this work?
If you look at your Traceback error, you can see where you went wrong. In line 1 of your test13.py file and in in line 5 of the win32 package. The first thing to ask is "what does the error mean?" Take a look here: import win32api error in Python 2.6. Although it is a reference for Python 2, it should give you a good idea of what to do in your similar situation. It seems like you have to move some dll files from where ever they are currently located to the package directory in your Python36-32 directory. For your possible Python 3 needs, here is a good reference: https://github.com/pyinstaller/pyinstaller/issues/1840
recently i have created this topic and did not get the answer.
after that i edited this and added 2 screenshots.
right now i tested another temporary email library and got the same error :((
this library :
pip install python-guerrillamail
code python 2.7:
from guerrillamail import GuerrillaMailSession
session = GuerrillaMailSession()
print session.get_session_state()['email_address']
print session.get_email_list()[0].guid
it seemed i cant never work like this email lib.
updated after remove email.pyc:
Traceback (most recent call last):
File "C:\Users\11\Desktop\untitle.py", line 1, in <module>
from guerrillamail import Guerrillamail
ImportError: cannot import name Guerrillamail
Your module email.py, is shadowing, or hiding, the email package in Python's standard library. This is causing the error: in the traceback you can see that an error is being reported when the statement import email is executed.
Rename your file to something else, for example myemail.py.
I changed the code to " from guerrillamail import * " that is worked. this code seems import all things to program, maybe it causes to be heavy and executing time.
thanks to #snakecharmerb .
For this problem (stackoverflow.com/questions/4086435/), I tried to make a Python 3 version of the library python-websocket (github.com/mtah/python-websocket/), here is my code: https://gist.github.com/663175.
Blender comes with his own Python 3.1 package, so I added my file directly in its «site-packages» folder. I get this error now:
Traceback (most recent call last):
File "websocket.py", line 6, in
AttributeError: 'module' object has no attribute 'WebSocket'
when running this code in Blender:
import sys, os, asyncore, websocket
def msg_handler(msg):
print(msg)
socket = websocket.WebSocket('ws://localhost:8080/', onmessage=msg_handler)
socket.onopen = lambda: socket.send('Hello world!')
try:
asyncore.loop()
except KeyboardInterrupt:
socket.close()
I found that a __init__.py is needed so I added but it didn't help…
What I am doing wrong here ? Thanks for your help.
It looks like you called your script websocket.py, so the import of websocket finds the script itself, instead of the installed module by that name. Rename the script to something else (and if it created a websocket.pyc file, delete that.)