Python: ImportError: No module named _pluggy - python

I am getting ImportError: No module named _pluggy error when running tests using pytest.
Then I tried installing pluggy using pip install pluggy. It installs pluggy==0.6.0 successfully, but is still giving the error.
Versions List (From running pip freeze | grep pytest)
pytest==3.3.1
pytest-cov==2.5.1
pytest-metadata==1.5.0
pytest-runner==3.0
pluggy==0.6.0
Python 2.7.12
Shown below is the stack trace
Tests run successfully when run in a virtualenv. What are the possible causes which can cause this error in a non-virtualenv environment?

As it was pointed out by #bouteillebleu the issue was in pytest-metadata package.
The solution was to upgrade the package
pip install --upgrade pytest-metadata

Related

Why do I get 'No module named 'currency-symbols' when importing xls2xlsx, even though 'pip install currency-symbols' returns requirement satisfied?

My IDE is Spyder and the distribution I am using is miniconda. I use pip install in the anaconda prompt window (as I usually do).
'pip install xls2xlsx' seems to run fine and install the package.
When I try 'from xls2xlsx import XLS2XLSX' I get the following error:
ModuleNotFoundError: No module named 'currency-symbols'
If I try 'pip install currency-symbols' , I get:
'Requirement already satisfied: currency-symbols in c:\users\user\miniconda3\lib\site-packages (2.0.2) '
I can see both directories in the site-packages directory.
So I had the same or very similar problem, my trace-back said it could not import currency_symbols. I found that the module it was trying to import was the constants from that package. So I went into the py file where xls2xlsx had the issue
"htmlxls2xlsx.py" my traceback said line 40..
currency_symbols_constants =
importlib.import_module('currency-symbols.constants')
I noticed this was part of an 'exception' so I fixed line 37 from import currency_symbols.constants as currency_symbols_constants to import currency_symbols._constants as currency_symbols_constants
Now it imports just fine.
I also had version 2.0.2 of currency-symbols installed, but my working host was using 2.0.1. I discovered that if you install 2.0.1, the issue did not occur.
pip3 install -Iv currency-symbols==2.0.1

Cannot seem to download SimpleElastix: file.whl wheel not recognized/import not recognized

I'm trying to install SimpleElastix for python. As far as I can tell, you can either download a whl file from https://simpleelastix.github.io/#download
or simply pip install as shown here: https://pypi.org/project/SimpleITK-SimpleElastix/
I first tried downloading it and am trying to install SimpleITK-0.9.1rc1.dev163-cp34-cp34m-win_amd64.whl that I have saved to drive.
I am using the following (pip has been updated):
(hids3) C:\Windows\system32>python --version
Python 3.8.0
(hids3) C:\Windows\system32>pip --version
pip 22.0.4 from C:\Users\kated\anaconda3\envs\hids3\lib\site-packages\pip (python 3.8)
I try to run pip install SimpleITK-0.9.1rc1.dev163-cp34-cp34m-win_amd64.whl
and get the following error:
ERROR: SimpleITK-0.9.1rc1.dev163-cp34-cp34m-win_amd64.whl is not a supported wheel on this platform.
According to Error "filename.whl is not a supported wheel on this platform" , this could be caused by a downloading the .whl file for a wrong python version. I would expect python 3.8 to support a CPython 3.4 version or am I wrong for assuming this?
Alternative way to download SimpleElastix: https://pypi.org/project/SimpleITK-SimpleElastix/
I also tried running
pip install --user SimpleITK-SImpleElastix
in the terminal, which worked, but when I run
import SimpleITK as sitk
sitk.Elastix()
I get
AttributeError: module 'SimpleITK' has no attribute 'Elastix'
Anyone have any idea what I'm doing wrong in either case?

How can i install python modules that have spaces in between?

I wanted to run a script that would scan my network and that script uses a awesome library called who-is-on-my-wifi. I have installed the module to run the script but i get errors from the prompt saying that it cannot detect such a module in the system.
This is the script.
from who_is_on_my_wifi import *
WHO = who()
for i in range(0, len(WHO)):
print(WHO[i])
And this is the error that i get.
python scanner.py
Traceback (most recent call last):
File "scanner.py", line 1, in <module>
from who_is_on_my_wifi import *
ImportError: No module named who_is_on_my_wifi
This is the proof that i have installed the module
pip3 install 'who_is_on_my_wifi'
Requirement already satisfied: who_is_on_my_wifi in /home/harein/.local/lib/python3.8/site-packages (1.2.0)
Requirement already satisfied: getmac in /home/harein/.local/lib/python3.8/site-packages (from who_is_on_my_wifi) (0.8.2)
Requirement already satisfied: python-nmap in /home/harein/.local/lib/python3.8/site-packages (from who_is_on_my_wifi) (0.6.1)
Any suggestions on how i can avoid this can continue executing my script ?
EDIT
The script finally executed the way i want by changing the,
python scanner.py to python3 scanner.py
You guys were right, it was the way how i executed the script that generated this error and it was not a problem in the module apparently.
I would like to thank everyone who gave the support.<3
When trying to
import this_is_not_a_module
the error you get:
ImportError: No module named this_is_not_a_module
is the error raised by Python 2.
Python 3 would raise a different one:
ModuleNotFoundError: No module named 'this_is_not_a_module'
So, your actual problem is that your system tries to execute your script with some Python 2 version, while you installed your module for your Python 3.8 version.
sometimes you can't import modules because you have installed two python versions(or conda along with it). if you have, delete one of your python versions or activate conda and try importing your module, or just try:
pip uninstall who_is_on_my_wifi
pip install who_is_on_my_wifi
I usually tend to install modules per project and use virtualenv for it.
It kind of links respective versions of programs (like python interpreter, pip and so on) and takes care of PYTHONPATH and the way of installed dependencies.
$ pip3 install virtualenv
$ virtualenv whoisonwifi
$ source whoisonwifi/bin/activate
$ pip --version
pip 21.0.1 from
/mnt/devel/workonhome/whoisonwifi/lib/python3.7/site-packages/pip
(python 3.7)
$ pip install 'who_is_on_my_wifi'
from there your code (sort of) works for me.

keep getting python ModuleNotFoundError: No module named

I am working on a raspberry pi python project and every time I import a package I get the same error ModuleNotFoundError: No module named ''. for example I am trying to add the ambient_api package
I followed the steps in their set up:
pip install ambient_api
Added the imports at the top of my file:
from ambient_api.ambientapi import AmbientAPI
api = AmbientAPI()
but I am getting the error:
ModuleNotFoundError: No module named 'ambient_api'
This is happening with all the imports I am trying to add and I cant figure out what I am missing.
when I was looking on google I came across __init__.py might be a solution but I am not sure how this works?
edit:
here is what was output when I installed:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: ambient_api in /home/pi/.local/lib/python2.7/site-packages (1.5.2)
Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from ambient_api) (2.21.0)
Requirement already satisfied: urllib3 in /usr/lib/python2.7/dist-packages (from ambient_api) (1.24.1)
version in my terminal:
pi#raspberrypi:~/Raspberry-Pi-Greenhouse $ python --version
Python 2.7.16
but it looks like the version in the shell in the ide when I run the program is saying:
Python 3.7.3 (/usr/bin/python3)
As explained by #JaFizz in Pytorch is installed but do not working ubuntu 18.04 it solved by giving an alias and installing correctly to desired python version (there were two pythons installed on the same machine)
First it was necessary to specify the location of the python, example:
alias python=/usr/local/bin/python3.6
Then install it:
python pip install <package name>

NoModuleFound Error even when I install the module

I am trying to import some libs, including:
from past.builtins import xrange
problem is, I keep getting this error:
ModuleNotFoundError: No module named 'past'
I've successfully installed and upgraded future, both localy AND on my virtualenv:
C:\Users\JON>pip install future
C:\Users\JON>pip install --upgrade future
(.env) C:\Users\JON>pip install future
(.env) C:\Users\JON>pip install --upgrade future
still, when I run this import on Jupyter I get the error above.
I should mention I'm using Windows 10 and Anaconda+Jupyter for python 3.6
Anybody has an idea why this happens and how to fix it?

Categories

Resources