I am using elementary OS and I want to make my own notifications using python 3. I know that a simple way of doing that is by import subprocess. However, reading around the web I found out that it's not the most appropriate way of doing it. Instead I should use from gi.repository import Notify but I get this error
__main__:1: PyGIWarning: Notify was imported without specifying a version first. Use gi.require_version('Notify', '0.7') before import to ensure that the right version gets loaded.
I have been trying to solve this and using the following code seems to work.
import gi
gi.require_version("Notify", "0.7")
from gi.repository import Notify
Can someone explain the why this error was produced in the first place and why this is the way to solve it (if it's the correct way)? Thank you in advance.
PS. I asked in the www.elementaryos.stackexchange.com but I didn't get any answer. Maybe they are not familiar with this.
You can try installing package pip install gi==0.0.7 or pip install pgi==0.0.7
OR
you can use pgi instead of gi.
It happens because of version mismatch issue. I have same problem and just tried on my system and it works.
Related
I'm trying to run stable diffusion on my local pc. It's a macbook pro m1. Even though I did follow every single step, I keep getting an import error. What might possibly be the reason and how may I fix it?
ImportError: cannot import name 'WatermarkEncoder' from 'imWatermark'
I was referring an online tutorial so I did end up searching through the comments. Found nothing so far.
If you look in the txt2img.py script it references https://github.com/ShieldMnt/invisible-watermark
Install with pip install invisible-watermark
It seems they forgot to add it into requirements.txt or smt like that.
If you continue getting the error after invisible-watermark installation, change the line from imWatermark import WatermarkEncoder in txt2img.py to from imwatermark import WatermarkEncoder (lowercase)
I have been trying to use the noise module in Python for a game I was making. I am on the Mac OS, and I used pip3 install noise to download the module. I uninstalled and reinstalled it multiple times, without the wheel library, and with, as it recommended. The noise module itself downloads fine, but every time I try to import pnoise from it, I get an ImportError.
Just straight up importing noise (import noise) gives me no error, it just prints a string of numbers to my console. Also, downloading and running the module in a virtual environment works, so it must be something on my computer or OS.
Code: from noise import pnoise1
Error: ImportError: cannot import name 'pnoise1' from 'noise'
I have looked for a while for a solution, but nothing has seemed to help, it just doesn't work. The only information I have found is that this may be a file problem, but I haven't found out how to fix it.
Any help would be greatly appreciated.
Edit:
I ended up figuring it out. I was importing a file by the same name instead of the library. Thanks for the help, everyone!
To me it works ok. Have you installed it correctly via pip/pip3?
Ended up figuring it out, I was importing a file of mine instead of the library. Thanks for the help!
I have a simple user interface with tkinter that works perfectly fine. However, when I import another python module, whenever I use the button that calls this specific line of code (the second one):
from tkinter.filedialog import *
files = askopenfilenames()
(which works fine normally and even gets the files etc...) Jupyter notebook crashes without any error message, making it hard to understand what the problem is. After investigating, I discovered that this error happens because in the other module that I import in this interface file, there is this import:
from sklearn.cluster import KMeans
When I comment out this import in the other module and try again, the button event works fine and allows me to select files. However, when I uncomment that import line again, the same problem happen.
Since there is no error message, it is hard to understand the problem and I searched but couldn't find any known problem between KMeans and this Tkinter function. Any help would be really appreciated.
Due to the lack of error message, it was impossible to find the exact cause of the problem. Suspecting a conflict in libraries, I created a new environment and installed libraries again. If anyone faces a similar issue, I suggest using conda to install libraries instead of pip as much as possible, and only use pip when no other choice is present.
I am currently trying to import some libraries/modules and everytime I try, it wont work and displays the pylint import error.
Here is what im trying to do:
import pycolors
I am using pylint, and I don't know how to fix this. I have watched several videos and done a ton of research, but none of them helped.
Pylint need to be in an environment where Pycolor is installed in order to not raise a warning . It's not clear whether the problem is when launching with python or analysing with pylint but in both case the solution is to install Pycolor: pip install Pycolor (If this is the one you want : https://pypi.org/project/Pycolor/)
Looking at this link, when I install Python it says Tcl/Tk/Tkinter will also install, but when I run a game in Python, I get an import error. I have my usual import statements as well, but it's still not working. I also looked at this very similar problem, but the answer isn't working for me.
import simplegui
import random
from tkinter import *
Assuming you are using Python 3.x, programs must be run with python3 my-program.py (not python my-program.py).
I am assuming you are using python2.
Try this
from Tkinter import *
You are putting wrong name for module. This will work.
EDIT AFTER COMMENT
For python3 install this python3-tk and your code will work.