Attribute error : module "pytest" has no attribute "hookimpl" - python-3.x

I have installed python 3.8.3 in windows 8/64 bit.. I need to start with pytest...path has been set properly... In Pycharm I am getting
Attribute error : module "pytest" has no attribute "hookimpl"
All the plugins installed as per the latest version

Pytest doesn't supports Python 3.8 yet.
Supported versions for Pytest
Python 3.5
Python 3.6
Python 3.7
PyPy3
Create a new virtualenv in Pycharm with these versions. If you don't know how here is a link for you.
Pycharm Configuring Python Interpreter
Also if you are interested you can find more info about Pytest Installation

There appears to be an issue with a Magic String here. Make sure you dont have any file named identically to any internal python code. I changed my package name from 'pytest' to 'pytestdemo' and this error was resolved.

Check your pytest project/package name, it should not start with 'Test'. I got same issue when project/package name was "Test". Changing the project/package name solved the issue.

Related

ModuleNotFoundError: No module named 'sklearn.utils._typedefs'

When I try to execute the exe file made my pyinstaller I got the error message
No module named 'sklearn.utils._typedefs'. I use from sklearn.ensemble import RandomForestClassifier in my python code.
I did use the --hidden-import and solve the problem before but when I try use the different version's python it didn't works
The command I use is
pyinstaller --hidden-import="sklearn.utils._cython_blas" --hidden-import="sklearn.neighbors.typedefs" --hidden-import="sklearn.neighbors.quad_tree" --hidden-import="sklearn.tree._utils" -F myprgname.py
The old setting works
Python 3.6.8
pyinstaller==4.6
pyinstaller-hooks-contrib==2021.3
python-dateutil==2.8.2
pytz==2021.3
scikit-learn==0.24.2
The new setting (got error message above)
Python 3.7.8
pyinstaller==5.0.1
pyinstaller-hooks-contrib==2022.4
python-dateutil==2.8.2
pytz==2022.1
scikit-learn==1.0.2
any suggestion is appreciated.
Had the same issue today, I resolved it by adding news hidden imports :
--hidden-import="sklearn.utils._typedefs"
This one may be sufficient for your issue, but for me, I had to add also :
--hidden-import="sklearn.neighbors._partition_nodes"
Here is the full command that I used :
pyinstaller --hidden-import="sklearn.utils._cython_blas" --hidden-import="sklearn.neighbors.typedefs" --hidden-import="sklearn.neighbors.quad_tree" --hidden-import="sklearn.tree._utils" --hidden-import="sklearn.neighbors._typedefs" --hidden-import="sklearn.utils._typedefs" --hidden-import="sklearn.neighbors._partition_nodes" --onefile MyPythonScript.pyw
My environment :
Python 3.9.12
Pyinstaller 5.0.1
pyinstaller-hooks-contrib==2022.4
python-dateutil==2.8.2
scikit-learn==1.0.2
pytz == none
I had the same issue and I could't solve it adding the --hidden-import flag.
I had scikit-learn==1.0.2 and pyinstaller==4.10
Downgrading it to scikit-learn==1.0.1 solved the problem.
pip install -U scikit-learn==1.0.1
I guess it is a compatibility problem.
ModuleNotFoundError: No module named 'sklearn.utils'.
This is the problem you have when converting from python to an executable.
Knowing that I am using python 3.8, I had the same issue today. I resolved it by adding new hidden imports:
--hidden-import="sklearn.utils._typedef"
Didn't accept it at the command prompt CMD

Pandas install or import in IBM SPSS Statistics Version 26

I have installed the latest version of IBM SPSS Statistics(Version 26) which has pre installed python 3.4 and 2.7. i am trying to use version 3.4 python. i am able to import modules like pip , sys , os etc. i tried pandas the same way. i am unable to do so. getting error no module found. Hence going through our forum and IBM support did the following changes.
received the following error
1) tried pointing the site-packages via
import sys
# Assuming windows and standard python folder here.
sys.path.append(r"D:\Python34\Lib\site-packages")
2) changed the path in the settings of SPSS
3) Tried installing pip in the below folder as suggested in the forum but got message i have already installed the updated version.
C:\Program Files\IBM\SPSS\Statistics\Subscription\Python3
4) following versions of python were installed
have tried what i could. Need your expertise help to fix the same which will help me to install/use modules needed for SPSS. Thanks.
This is going to be painful to explain, I'll do my best.
As far as I can tell, you're on windows. Usually when we need a new package, we just open cmd and type pip install xxx (assume you added python to path when installing it). The reason that this works, is because when you type pip install xxx in cmd, windows recognize pip to be a command because python path is in system variables. Windows know that I can execute pip install with this python path.
However for SPSS python (3.4), that python had a different path in the system. Thus when you only have the 3.7 or 3.8 python in path, windows cannot install package to you 3.4 python, and I'm not sure if you can have more than one python path in system.
In order to fix this, you need to first figure out what's the path to your 3.4 python, then in this page you can follow the instruction to remove your 3.7 or 3.8 python in path, and add your 3.4 path, then you can do pip install xxxx for whatever package you want
I did the same thing with a arcgis python distribution, hope this works for you. If the attached page does not work, just google add python path to windows and look for a instruction that works on you PC
Oh and the reason that you can import pip, sys and some other package but not pandas, is because python is 'battery included', it comes with tons of packages pre-installed for additional functionality, but pandas is not one of them.
Fixed it since my ananconda had version 3.7 .i created virtual environment and installed 2.7 python with anaconda package. Pointed SPSS to the 2.7 folder and was able to import pandas.

PyCharm 2017.1, No module named 'kivy'

I could use (troubleshooting)help with getting Kivy imported in PyCharm. I am using:
Anaconda with Python 3 on 64-bit Windows 10 Pro
PyCharm 2017.1
Packages: NumPy, SciPy, BeautifulSoup, Pandas, Scrapy, Pattern, NetworkX, NLTK, scikit-learn, Selenium
I have installed Kivy following the instructions at https://kivy.org/docs/installation/installation-windows.html#installation
As evident from the screen shot, no errors occurred.
Still, when I run "import kivy" from PyCharm I get "ModuleNotFoundError: No module named 'kivy'".
I ran through the installation with someone on the #kivy channel and was assured that kivy is successfully installed.
When I pass import kivy; print(kivy.file) to the interpreter (opened from the CMD command line), I get returned among others:
C:\Users\Steve\Anaconda3\lib\site-packages\kivy\__init__.py
Someone on #kivy suggested I check where PyCharm looks for kivy. How do I figure that out?
I'd appreciate any suggestions to identify the problem / resolve my issue.
Indeed, the installation of Kivy went fine. The problem turned out to be that I had to select the correct (updated) interpreter in the PyCharm settings.

Issues installing yhat on Python 3.5

I just got access to use a ScienceOps server at my work and pip installed the yhat module. The first issue with the installation was that the poster dependency was not compatible with Python 3.x, so I installed: https://github.com/mrd1no/poster-0.8.1-for-Python-3.4
Yhat then correctly installed as a result. However, now when I try to run the Hello World example, I am running into the issue of:
ImportError: No module named 'input_and_output'
This comes from the model.py file where:
from input_and_output import df_to_df, parse_json, preprocess
I did some searching and couldn't find any evidence of this module, does that module only exist in Python 2.x?
Any help or guidance is much appreciated.
EDIT:
It looks like input_and_output is a python file under a sub-directory of yhat. However, the models.py still can't find the input_and_output file
yhat isn't compatible with Python 3.x, it is reccomended to work with python 2.7.x

Anaconda3 libhdf5.so.9: cannot open shared object file [works fine on py2.7 but not on py3.4]

I just tried to use pd.HDFStore in IPython Notebook with a Python 3 kernel (Anaconda 2&3 on Ubuntu 14.04)
import pandas as pd
store = pd.HDFStore('/home/Jian/Downloads/test.h5')
but it throws the following error
ImportError: HDFStore requires PyTables, "libhdf5.so.9: cannot open shared object file: No such file or directory" problem importing
I initially thought it's because pytables is somehow missing, but when I check $source activate py34 and $conda list, pytables 3.2.0 is already installed under anaconda python3 environment.
Also, if I switch to Python 2, for example, $source activate py27 and start ipython notebook, it works properly and no import error is thrown.
I guess that I must miss something for configuring pytables under anaconda python 3 env, but I cannot figure it out. Any help is highly appreciated.
Update:
I just tried on a fresh install of Anaconda3-2.3.0-Linux-x86_64 from official website and it ends up with the same error. When I try $locate libhdf5.so.9 in command line, nothing shows up.
This is a known issue that we are working on. When it is fixed, conda update --all will update the libraries and fix the issue.

Resources