I tested a python script to send anythink with Pushover. But I get the error "ImportError: No module named pushover"
My installed Versions:
# pip install python-pushover
Collecting python-pushover
Using cached https://files.pythonhosted.org/packages/6f/3d/144a0137c749bd152c3ab7f4d3ce8fe1455168dab36c2fcd900d3fab16ad/python-pushover-0.4.tar.gz
Requirement already satisfied: requests>=1.0 in /usr/local/lib/python3.5/dist-packages (from python-pushover) (2.21.0)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.5/dist-packages (from requests>=1.0->python-pushover) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.5/dist-packages (from requests>=1.0->python-pushover) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.5/dist-packages (from requests>=1.0->python-pushover) (2018.11.29)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.5/dist-packages (from requests>=1.0->python-pushover) (2.8)
Installing collected packages: python-pushover
Running setup.py install for python-pushover ... done
Successfully installed python-pushover-0.4
# python -V
Python 2.7.13
# python3 -V
Python 3.5.3
The scriptheader:
#!/usr/bin/env python
import pushover
I have tried with pip(3) to install python-pushover but with no success.
I faced this exact error today. This is due to co-existing of different versions of python in your system.
Do, /usr/bin/python3 if the module was installed for py3 and just /usr/bin/python for py2 before running the script.
Refer Installed module using pip, not found for more.
In my case, you should :
uninstall that package:
pip uninstall pushover
and install the correct package:
pip install python-pushover
And your code will work fine.
Related
I'm trying to install the discord-1.7.3 package. pip installs discord-1.7.3 and discord.py-2.0.1. My program is incompatible with version 2.x.x so I need only version 1.7.3 to install. The answers to this question suggest telling pip what version to install, but this doesn't work:
$ python3 --version
Python 3.9.2
$ pip install 'discord==1.7.3'
Collecting discord==1.7.3
Using cached discord-1.7.3-py3-none-any.whl (1.1 kB)
Collecting discord.py>=1.7.3
Using cached discord.py-2.0.1-py3-none-any.whl (1.1 MB)
Requirement already satisfied: aiohttp<4,>=3.7.4 in /home/username/.local/lib/python3.9/site-packages (from discord.py>=1.7.3->discord==1.7.3) (3.8.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /home/username/.local/lib/python3.9/site-packages (from aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (6.0.2)
Requirement already satisfied: attrs>=17.3.0 in /home/username/.local/lib/python3.9/site-packages (from aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (22.1.0)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /home/username/.local/lib/python3.9/site-packages (from aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (4.0.2)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /home/username/.local/lib/python3.9/site-packages (from aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (2.1.1)
Requirement already satisfied: aiosignal>=1.1.2 in /home/username/.local/lib/python3.9/site-packages (from aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (1.2.0)
Requirement already satisfied: yarl<2.0,>=1.0 in /home/username/.local/lib/python3.9/site-packages (from aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (1.8.1)
Requirement already satisfied: frozenlist>=1.1.1 in /home/username/.local/lib/python3.9/site-packages (from aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (1.3.1)
Requirement already satisfied: idna>=2.0 in /home/username/.local/lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp<4,>=3.7.4->discord.py>=1.7.3->discord==1.7.3) (3.3)
Installing collected packages: discord.py, discord
Successfully installed discord-1.7.3 discord.py-2.0.1
... you see discord.py-2.0.1 was installed anyway.
This answer suggests using pkg_resources to control what version is imported, but that doesn't work either:
$ cat test.py
import pkg_resources
pkg_resources.require("discord==1.7.3")
import discord
print(discord.version_info)
$ python3 test.py
VersionInfo(major=2, minor=0, micro=1, releaselevel='final', serial=0)
"How to only install (or import) a specific package version?" is the wrong question in this case.
You don't want to install the discord package at all, since it's just a mirror/placeholder.
This is a mirror package!
It is recommended to install discord.py instead.
If you want version 1.7.3 of Discord.py, then install the correct package:
pip install discord.py==1.7.3
In fact, the discord placeholder package doesn't even contain any code:
$ unzip -l discord-2.0.0-py3-none-any.whl
Archive: discord-2.0.0-py3-none-any.whl
Length Date Time Name
--------- ---------- ----- ----
381 08-20-2022 23:51 discord-2.0.0.dist-info/METADATA
92 08-20-2022 23:51 discord-2.0.0.dist-info/WHEEL
1 08-20-2022 23:51 discord-2.0.0.dist-info/top_level.txt
296 08-20-2022 23:51 discord-2.0.0.dist-info/RECORD
All it does is require discord.py>=2.0.0:
$ unzip -p discord-2.0.0-py3-none-any.whl discord-2.0.0.dist-info/METADATA
Metadata-Version: 2.1
Name: discord
Version: 2.0.0
Summary: A mirror package for discord.py. Please install that instead.
Home-page: https://github.com/Rapptz/discord.py
Author: Rapptz
License: UNKNOWN
Platform: UNKNOWN
Description-Content-Type: text/markdown
Requires-Dist: discord.py (>=2.0.0)
I'm using Windows 10.
In my project folder, I'm trying to test it as an exe.
So, I did this to install Pyinstaller:
py -m pip install pyinstaller
And it said it installed.
But when I did py -m pyinstaller emu.py, it just returned this:
C:\Users\tux\AppData\Local\Programs\Python\Python310\python.exe: No module named pyinstaller
Can someone help?
If I try to install pyinstaller using PIP again, it comes up with this error:
Requirement already satisfied: pyinstaller in c:\users\tux\appdata\local\programs\python\python310\lib\site-packages (5.3)
Requirement already satisfied: pyinstaller-hooks-contrib>=2021.4 in c:\users\tux\appdata\local\programs\python\python310\lib\site-packages (from pyinstaller) (2022.8)
Requirement already satisfied: altgraph in c:\users\tux\appdata\local\programs\python\python310\lib\site-packages (from pyinstaller) (0.17.2)
Requirement already satisfied: pefile>=2022.5.30 in c:\users\tux\appdata\local\programs\python\python310\lib\site-packages (from pyinstaller) (2022.5.30)
Requirement already satisfied: pywin32-ctypes>=0.2.0 in c:\users\tux\appdata\local\programs\python\python310\lib\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: setuptools in c:\users\tux\appdata\local\programs\python\python310\lib\site-packages (from pyinstaller) (58.1.0)
Requirement already satisfied: future in c:\users\tux\appdata\local\programs\python\python310\lib\site-packages (from pefile>=2022.5.30->pyinstaller) (0.18.2)
It's saying Pyinstaller is already installed, but python doesn't recognise it.
Before you ask, if I try to just run pyinstaller as a standalone command, it says it cannot find pyinstaller.
Edit: It's been over a month and nobody has replied.
Forget it. I'm just not gonna make the application.
Did you try the generic way
pip install pyinstaller
also refer to this pypi link https://pypi.org/project/pyinstaller/
I am trying to install Ansible-3.0.0 on Ubuntu 20.04, but it's not working out. It's still showing me the old version i.e 2.10.9.
I have already executed install command, which shows it's working but still pointing to old version. What am I doing wrong?
Terminal:
ansible --version
ansible 2.10.9
configured module search path = ['/home/akshay/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/akshay/.local/lib/python3.8/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
Then I installed Ansible as regular user.
pip3 install --upgrade ansible==3.0.0
/usr/lib/python3/dist-packages/secretstorage/dhcrypto.py:15: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
/usr/lib/python3/dist-packages/secretstorage/util.py:19: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: ansible==3.0.0 in /home/akshay/.local/lib/python3.8/site-packages (3.0.0)
Requirement already satisfied: ansible-base<2.11,>=2.10.5 in /home/akshay/.local/lib/python3.8/site-packages (from ansible==3.0.0) (2.10.9)
Requirement already satisfied: jinja2 in /home/akshay/.local/lib/python3.8/site-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (3.0.1)
Requirement already satisfied: cryptography in /home/akshay/.local/lib/python3.8/site-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (3.4.7)
Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (5.3.1)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (20.3)
Requirement already satisfied: cffi>=1.12 in /home/akshay/.local/lib/python3.8/site-packages (from cryptography->ansible-base<2.11,>=2.10.5->ansible==3.0.0) (1.14.6)
Requirement already satisfied: pycparser in /home/akshay/.local/lib/python3.8/site-packages (from cffi>=1.12->cryptography->ansible-base<2.11,>=2.10.5->ansible==3.0.0) (2.20)
Requirement already satisfied: MarkupSafe>=2.0 in /home/akshay/.local/lib/python3.8/site-packages (from jinja2->ansible-base<2.11,>=2.10.5->ansible==3.0.0) (2.0.1)
But still the same
akshay#akshay-System-Product-Name ~/D/R/p/n/c/e/staging-database (master)> ansible --version
ansible 2.10.9
configured module search path = ['/home/akshay/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/akshay/.local/lib/python3.8/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
Even tried with sudo
akshay#akshay-System-Product-Name ~/D/R/p/n/c/e/staging-database (master)> sudo pip3 install ansible==3.0.0
[sudo] password for akshay:
Requirement already satisfied: ansible==3.0.0 in /usr/local/lib/python3.8/dist-packages (3.0.0)
Requirement already satisfied: ansible-base<2.11,>=2.10.5 in /usr/local/lib/python3.8/dist-packages (from ansible==3.0.0) (2.10.9)
Requirement already satisfied: jinja2 in /usr/local/lib/python3.8/dist-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (3.0.1)
Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (5.3.1)
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (2.8)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.5->ansible==3.0.0) (20.3)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.8/dist-packages (from jinja2->ansible-base<2.11,>=2.10.5->ansible==3.0.0) (2.0.1)
what am I missing?
I am trying to fix this issue
Restriction: only Ansible =2.11.X is supported.
You have gotten bitten by the confusing ansible rebrand; ansible from pip's perspective is no longer just one thing, it's a distribution of selected versions of ansible-collections plus a selected version of "ansible-core" (previously known as ansible), with the latter selected version that you're seeing emitted by --version.
You will never(?) see 3.0.0 (nor 4.2.0, the current version) output by ansible --version because the ansible command is, in fact, still 2.10.5, but the ansible PyPI package is the 3.0.0 that is being installed
You can confirm this theory for yourself by installing ansible into a docker container, or virtual machine, or whatever clean environment, and then run ansible --version and observe it does not say the same version as you requested installed by pip
It's a huge, monster, terrible mess
I am running Catalina MacOS with python 3.7.5. I am trying to run an ansible script to install a VM. This Requires python >= 2.6 and PyVmomi. I have installed PyVomi and pyVim via pip. Both were installed successfully. When I run the playbook, I get the error message below. Not sure what I am missing.
TASK [Create a virtual machine on given ESXi hostname] *************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pyVim
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (PyVmomi) on MacBook-Pro.local's Python /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python. Please read module documentation and install in the appropriate location"}
ArunJose_Intel is correct. The module is pyvmomi, not pyVim. Although the error indicates that the pyVim library was missing. It was misleading as I could see it in my directory. Following his advice I changed the pip install command to install pyvmomi instead.
pip install pyvmomi
I was able to run the python script with pyVim imported. Thank you Arun.
You might have installed PyVomi and pyVim for the wrong python executable. You have to make sure you are installing via pip to the right python. You are installing the packages to the python3.x present in your machine. What you have to do is to install the pip packages to the python of the playbook
I fixed it.
pip3 install ansible
That made ansible use python3
Sorry for the confusion. I have installed this via pip3, is yes they are installed in the python3 directories.
pip3 install PyVmomi
Requirement already satisfied: PyVmomi in /usr/local/lib/python3.7/site-packages (6.7.3)
Requirement already satisfied: requests>=2.3.0 in /usr/local/lib/python3.7/site-packages (from PyVmomi) (2.22.0)
Requirement already satisfied: six>=1.7.3 in /usr/local/lib/python3.7/site-packages (from PyVmomi) (1.13.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (2019.9.11)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (1.25.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (2.8)
pip3 install pyVim
Requirement already satisfied: pyVim in /usr/local/lib/python3.7/site-packages (3.0.2)
Requirement already satisfied: docopt in /usr/local/lib/python3.7/site-packages (from pyVim) (0.6.2)
Requirement already satisfied: prompt-toolkit<3.1.0,>=2.0.0 in /usr/local/lib/python3.7/site-packages (from pyVim) (3.0.2)
Requirement already satisfied: pyflakes in /usr/local/lib/python3.7/site-packages (from pyVim) (2.1.1)
Requirement already satisfied: pygments in /usr/local/lib/python3.7/site-packages (from pyVim) (2.5.2)
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (from pyVim) (1.13.0)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.7/site-packages (from prompt-toolkit<3.1.0,>=2.0.0->pyVim) (0.1.7)
I have only very rudimentary experience in Python. I am trying to install the package pyslim (see here on the pypi website). I did
$ pip install pyslim
Requirement already satisfied: pyslim in ./Library/Python/2.7/lib/python/site-packages/pyslim-0.1-py2.7.egg (0.1)
Requirement already satisfied: msprime in /usr/local/lib/python2.7/site-packages (from pyslim) (0.6.1)
Requirement already satisfied: attrs in /usr/local/lib/python2.7/site-packages (from pyslim) (16.3.0)
Requirement already satisfied: svgwrite in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (1.1.12)
Requirement already satisfied: jsonschema in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (2.6.0)
Requirement already satisfied: six in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (1.10.0)
Requirement already satisfied: numpy>=1.7.0 in /usr/local/lib/python2.7/site-packages/numpy-1.10.4-py2.7-macosx-10.11-x86_64.egg (from msprime->pyslim) (1.10.4)
Requirement already satisfied: h5py in /usr/local/lib/python2.7/site-packages (from msprime->pyslim) (2.8.0)
Requirement already satisfied: pyparsing>=2.0.1 in /usr/local/lib/python2.7/site-packages (from svgwrite->msprime->pyslim) (2.2.0)
Requirement already satisfied: functools32; python_version == "2.7" in /usr/local/lib/python2.7/site-packages (from jsonschema->msprime->pyslim) (3.2.3.post2)
But when I open python and try to import pyslim, it fails
> import pyslim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/remi/Library/Python/2.7/lib/python/site-packages/pyslim-0.1-py2.7.egg/pyslim/__init__.py", line 4, in <module>
from pyslim.slim_metadata import * # NOQA
File "/Users/remi/Library/Python/2.7/lib/python/site-packages/pyslim-0.1-py2.7.egg/pyslim/slim_metadata.py", line 1, in <module>
import attr
ImportError: No module named attr
So, I did
$ pip install attr
Requirement already satisfied: attr in /usr/local/lib/python2.7/site-packages (0.3.1)
and
$ pip install attrs
Requirement already satisfied: attrs in /usr/local/lib/python2.7/site-packages (16.3.0)
I restarted python and tried to import pyslim again but I keep receiving the same error message. I also tried to download and install the files from github by doing
$ git clone https://github.com/tskit-dev/pyslim.git
$ cd pyslim
$ python setup.py install --user
as indicated here on the pypi website. On this last line of code, I get a long output ending with
Download error on https://pypi.python.org/simple/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
No local packages or download links found for attrs
error: Could not find suitable distribution for Requirement.parse('attrs')
I am using Python 2.7.10 on a MAC OSX 10.11.6. Not sure if it matter but I usually install things with homebrew. I am using pip 18.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7).
Edit
$ which python
/usr/bin/python
$ which pip
/usr/local/bin/pip
Take a look to this other question that is related to the attrs package.
In your case, you have attr and attrs installed at the same time, and they are incompatible between them, so python is unable to resolve the package name on the import correctly.
You should use attrs only, so try uninstalling attr and try it again:
python -m pip uninstall attr
If, in the future, you need to have some packages incompatibles between them, take a look about using virtual environments in Python, which are really easy to use and will be very useful to play with packages and packages versions without break anything.
First uninstall pyslim. Use "pip uninstall pyslim". Then try installing again using
"conda install -c conda-forge pyslim"
Refer https://anaconda.org/conda-forge/pyslim