pynotify gets an error in python2.7 in windows10 - python

When i used to code pynotify for python2.7 in Windows 10 then it shows an error that module object has no attribute 'init'. And i have already done to install the init module but same error occur. so what are the possible solutions for this problem?
here the code is.
import pynotify
pynotify.init("Basic")
n = pynotify.Notification("Title","Some sample content")
n.show()

It looks like the pynotify package you are looking for was initially designed for linux and was never supposed work on windows
The pynotify package installable through pip is just a name collision, and is not what not what you are looking for. (as this stackoverflow thread shows : I have already installed pynotify, still getting error no module named pynotify)
The package you want has GTK dependencies and can be installed in linux-based systems through the package management system using commands like : sudo apt-get install pynotify.
Other similar packages like notify2 (https://pypi.python.org/pypi/notify2) require linux components like dbus, and thus are not windows compatible.
If you're looking for a way to make windows 10 notifications, you can probably have look at this repository https://github.com/jithurjacob/Windows-10-Toast-Notifications.

Related

Python PIP Install on Windows missing sub-directories?

My 11-year-old son is trying to follow Carol Vorderman's "Python Games for Kids" book, but is hitting a fundamental problem installing then using Actors module (p.52-onwards of book), on Windows 10. No instructions are provided for installing or importing this. We installed 'actors' (0.5.1b1) using pip:
pip install actors
The install "works" happily, no error is reported, and a (basic) actors installation appears. (We also tried python -m pip install actors, with exactly the same result).
However, any attempt to import actors; e.g.,
from actors import Actor
fails with:
ModuleNotFoundError: no module name 'actors.internal'
of line 29 of actors\__init__.py . Which is fair enough, because it does try to import messages from actors.internal, which does not seem to exist.
Things I checked following the import:
the downloaded .tar.gz file includes a load of subdirectories, including internal; but this doesn't make it into the disc. So it looks like pip isn't handling the .tar.gz file correctly? But it seems hard to believe that such a basic failure has gone undetected.
the disc has 116G free, so it's not running outta space.
I checked other answers (python pip install not working on windows, pip install on a shared directory (windows)), but they do not seem to apply here.
This is a bug in the distribution. It lists packages=['actors'], but it must list all subpackages (internal and utils) too.
The bug was reported in 2016 and still is unresolved. So we can guess the package is abandoned and there is not much you can do to fix it (other than forking and fixing it yourself).
You need to run your program through Pygame Zero, since it adds a few things for you (like opening a window, handling OS events, defining what an Actor or a Sprite are, etc).
Install it with: pip install pgzero
And then instead of running your file normally via python my_file.py
You should run it with: pgzrun my_file.py
If that doesn't work you can try putting import pgzrun on first line of the program and pgzrun.go() on the last line and then running the file normally with: python my_file.py.
Source for the fixes

from urllib3.util.ssl_ import ( ImportError: cannot import name ssl

My resources:
Python 2.7, Ubunutu 18.04, Pycharm, virtual box oracle
I have an automation solution built in python.
The solution can be run from both cmd or pycharm of course.
2 options to run automation solution.
python main.py args a,b,c...(run 1 suite of tests)
python jenkinsRun.py arg a,b,c...(run main.py with diff args each time -lets say 5 time for instance)
Once jenkinsRun.py is runnig it will execute each main.py like this:
os.system('python main.py %s %s %s %s %s %s'%(STD,config.VpcStackName, '-dryrun', 'false', '-tenant' ,config.PROD_STAGE_Tenant))
Note that this is how I implemented it 3 years ago..could be better ways like using __import__, but need way to pass arguments, etc...
Anyway, when run:
python main.py arg a,b,c..
All good.
When run:
jenkinsRun.py
which should run main each time with diff args I get exception:
"/home/ohad/.local/lib/python2.7/site-packages/botocore/httpsession.py", line 7, in <module>
from urllib3.util.ssl_ import (
ImportError: cannot import name ssl
This happend only when I run the code on my new environment (see resources above)
last week I had old virtul box with ubuntu 15.04 (old) which everything worked well (didn't touch the vode ever since).
I have installed on new virtual box from scratch libaries, drivers, etc, etc.
Any ideas?
Could be some issue with installation. I did re-installed on MAC and it worked
sudo pip install awscli --ignore-installed six
Just to make sure: are you certain that you are invoking Python 2.x ?
Ubuntu 18.04 has Python 3.x as default, so make sure that you are not accidentally starting the script using another python version.
I had a similar error after creating a new environment (which also uses Boto3). It turned out to be a DLL error (ImportError: DLL load failed), which was caught by SSL module resulting in the error from the question: ImportError: cannot import name ssl.
Solution for me was to add an additional folder to the path: path_to_anaconda/Anaconda3/Library/bin. In that way, DLL load succeeds and the given ImportError is resolved.
I was working in PyCharm when I hit this wall.
Solved it by redirecting the path to my Anaconda environment, which I keep better provisioned and up to date.
Update the latest version of awscli resolved on my Mac by the below command line.
curl "https://awscli.amazonaws.com/AWSCLIV2-2.0.30.pkg" -o
"AWSCLIV2.pkg" sudo installer -pkg AWSCLIV2.pkg -target /
Reference:
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html#cliv2-mac-install-cmd
After uninstalling, installing, even creating environments... this worked for me!
https://stackoverflow.com/a/60405693
In my case this issue came apparently from having colliding versions of boto3, botocore and awscli. This fixed the issue in my case:
pip install boto3 botocore awscli aiobotocore --ignore-installed
I was getting the same error on Win 10 and VS Code was pointing at the Conda interpreter. The issue was solved by installing Python 3.11 outside of Conda and pointing at the new interpreter. Don't forget to add the new Python to PATH and install boto3 afterwards.
If you are using boto3 as a dependency, there was a bug with how the boto3 dependencies were managed.
try running
pip3 install boto3 --upgrade to update boto3 and the issue should be resolved!
I am not sure why it worked. But, I had this issue in AWS Glue, and I was able to get around this problem by using Glue 3.0 instead of Glue 2.0.
Please update the latest urllib package:
run :
pip3 uninstall urllib3
pip3 install urllib3

python2-gobject on Arch linux ImportError: No module named gobject

I have some example file (download URL) to understand how to create Twisted chat with GUI.
In this particular file I have an exception ImportError: No module named gobject.
It's true, I have only gi and already installed:
sudo pacman -S python2-gobject
So I decide that this code for python3, and again fail. After pip install twisted I can't run code: ImportError: cannot import name 'gtk2reactor' appears.
How to run this code at least.
And how to prevent this in future, because I have the same error in many science packages for python.
P.S. installing from source impossible either.
make returns a lot of errors even if ./configure completes fine.
You may want to clarify your question a bit, but if you can't run code after you pip, or if your pip is broken a uninstall/reinstall of pip may be your best bet.
If you did successfully download the package, then I would dive into where you installed it and make sure the package is for the correct version of python, and that it is installed.
Juhaz from Freenode told me that the code in examples was pretty old and uses unmaintained bindings.
In case someone starts the same was as I am this question would be helpfull.
Try to look at wkPython, for example this post.

Installing mesos egg for python 2.7

I've installed mesos 0.26 successfully on a vm machine.
The installation has been performed on an ubuntu trusty thar system
by following this manual:
https://open.mesosphere.com/getting-started/install/
So far so good. I wanted to write a tiny python framwork.
For this I need to install the eggs via easy_install:
(I've downloaded the eggs accordingly for the trusty thar ubuntu and the 0.26 mesos):
wget http://downloads.mesosphere.io/master/ubuntu/14.04/mesos-0.26.0-py2.7-linux-x86_64.egg
easy_install mesos-0.26.0-py2.7-linux-x86_64.egg
all went fine, however, if I start python in the shell
and type in
import mesos.interface
I get the message: ImportError: No module named interface
As someone suggested, it may be that there is no longer a binding for python, or that they have renamed the API calls. Well, I looked in the version updates here:
http://mesos.apache.org/documentation/latest/upgrades/
Since the transition from 0.19.x to 0.20.x there hasn't been any changes regarding the mesos.interface part, or at least they are not mentioning it here.
To increase the confusion I also get the following error message when I'm typing in python: import mesos.native
There I receive: ImportError: No module named interface.mesos_pb2. To put it into a nutshell: what is going wrong here, and how can it be fixed? And yes, I've googled various web pages, with terms such as "mesos python bindings", mesos +api +python, etc. And yes, I have also consulted the official mesos webpage. There are nice refences for Java and C++ but not for python, or at least they are very well hidden.
Thanks in advance for any hints.
Solved. For what reasons ever:
export PYTHONPATH=${PYTHONPATH}:/usr/lib/python2.7/site-packages/
is required to set the PYTHONPATH. After that step it works like a charm.

How do I find out what Python libraries are installed on my Mac?

I'm just starting out with Python, and have found out that I can import various libraries. How do I find out what libraries exist on my Mac that I can import? How do I find out what functions they include?
I seem to remember using some web server type thing to browse through local help files, but I may have imagined that!
From the Python REPL (the command-line interpreter / Read-Eval-Print-Loop), type help("modules") to see a list of all your available libs.
Then to see functions within a module, do help("posix"), for example. If you haven't imported the library yet, you have to put quotes around the library's name.
For the web server, you can run the pydoc module that is included in the python distribution as a script:
python /path/to/pydoc.py -p 1234
where 1234 is the port you want the server to run at. You can then visit http://localhost:1234/ and browse the documentation.
Every standard python distribution has these libraries, which cover most of what you will need in a project.
In case you need to find out if a library exists at runtime, you do it like this
try:
import ObscureModule
except ImportError:
print "you need to install ObscureModule"
sys.exit(1) # or something like that
You can install another library: yolk.
yolk is a python package manager and will show you everything you have added via pypi. But it will also show you site-packages added through whatever local package manager you run.
just run the Python interpeter and type the command
import "lib_name"
if it gives an error, you don't have the lib installed...else you are good to go
On Leopard, depending on the python package you're using and the version number, the modules can be found in /Library/Python:
/Library/Python/2.5/site-packages
or in /Library/Frameworks
/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/site-packages
(it could also be 3.0 or whatever version)...
I guess it is quite the same with Tiger
Considering that in every operating system most of python's packages are installed using 'pip' (see pip documentation) you can also use the command 'pip freeze' on a terminal to print a list of all the packages you have installed through it.
Other tools like 'homebrew' for macOS (used when for some reason you can't install a package using pip) have similar commands, in this specific case 'brew list'.

Categories

Resources