ModuleNotFoundError: No module named 'pandas.core.indexes' - python-3.x

I wrote this code to load a dataset into a data frame. Dataset is given in a pickle file but it throws an error:
ModuleNotFoundError: No module named 'pandas.core.indexes'
import pickle
import pandas
dbfile = open(dataset loction,'rb')
df = pickle.load(dbfile)
I tried all the fixes given:
Updated the pandas
used df = pandas.read_picle(dataset location)
Tried installing pickle using pip but getting this error
C:\installs\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64>python -m pip install pickle
Collecting pickle
Could not find a version that satisfies the requirement pickle (from versions: )
No matching distribution found for pickle

That smells like the pickle file has been created with a different version of Pandas, and your currently installed Pandas doesn't have the pandas.core.indexes module that some of the data in the pickle requires.
Which version of Pandas are you using? Have you tried upgrading?
EDIT: Pandas 0.19.2 does not have that module:
$ pip install pandas==0.23.3
$ python
>>> import pandas.core.indexes as i
>>>
$ pip install pandas==0.19.2
$ python
>>> import pandas.core.indexes as i
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas.core.indexes'
>>>

I would suggest using pandas pickle method to read .pk file.
import _pickle as cPickle
with open('filename.pkl', 'rb') as fo:
dict = cPickle.load(fo, encoding='latin1’)
see doc here. Pickle Read

The answer by #AKX made me realise that it was probably a version problem Pandas. However, I only needed to upgrade.
pip install pandas --upgrade

Related

Import NumPy fails using Windows despite it being installed

I just managed to get this figured out but i couldn't find a post about my specific problem so here it is.
I had installed numpy using
py -m pip install NumPy
I got the following error when I tried to import it
>>> import NumPy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'NumPy'
I solved my problem by unistalling NumPy and re-installing it with all LOWER-CASE LETTERS i.e.
py -m pip install numpy
Now I can import it with lower case letters
>>> import numpy
>>>
hope this can help someone else save an hour.

AttributeError: 'property' object has no attribute '__name__'

While I am importing the pandas in my data science project I am getting such kind of error. Does anyone know what might cause this?
I tried with re-installation of pandas and python also
I also tried with wheel
import numpy as np
import pandas as pd
AttributeError
Traceback (most recent call last)
<ipython-input-2-b231533e2331> in <module>
1 import numpy as np
----> 2 import pandas as pd
3 from imblearn.over_sampling import SMOTE
4 from sklearn.model_selection import train_test_split
5 from sklearn.neighbors import KNeighborsClassifier
AttributeError: 'property' object has no attribute '__name__'
"I got the solution for same. It may be multiple python version installation problem in same system problem so you need to create a virtual environment for your data science project now steps for creating virtual environment...."
1. install python 3.x
2. install pip
3. pip install virtualenv #for creating virtual environment
4. mkvirtualenv folder_name #command for creating virtual environment
5 pip install pandas # run this command in virtual environment directory
now import pandas it will work fine.

Cannot access built-in webcam Python

I'm trying to access my laptop webcam and from what I have seen, I need to use the cv2 package. I downloaded it from PyPi but the contents of the file seem to be missing a lot of content as it only has __init__.py, cv2.cp36-win32.pyd, and opencv_ffmpeg320.dll. So whenever I try use things such as VideoCapture and imwrite, it says it cannot find a reference to them.
When I run the application, I get the following error message:
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "C:/Users/RedCode/PycharmProjects/FunApps/ImageFile.py", line 1, in <module>
import cv2
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cv2\__init__.py", line 7, in <module>
from . import cv2
ImportError: numpy.core.multiarray failed to import
I have got the numpy package installed and imported but it didn't fix the issue so I'm guessing that's not the actual cause of the problem, so I'm certain it must have something to do with the cv2 package.
The code I'm using right now is as follows:
import cv2
import numpy
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
if vc.isOpened(): # try to get the first frame
rval, frame = vc.read()
else:
rval = False
while rval:
cv2.imshow("preview", frame)
rval, frame = vc.read()
key = cv2.waitKey(20)
if key == 27: # exit on ESC
break
cv2.destroyWindow("preview")
I'm also using Python 3.6 and Windows 10 if that helps with anything.
How can I get my application to work?
In your case you can solve your problem by using the following command:
pip install -U numpy
Check existing package:
pip show numpy
And upgrade it via:
pip install numpy --upgrade
Check the path if you still got error:
> import numpy
> print numpy.__path__
You must install the latest version of numpy. Use the command pip install numpy --upgrade or you can just download the wheel file from http://www.lfd.uci.edu/~gohlke/pythonlibs/ . Just check for your python version and platform and download the necessary wheel file. Next use pip to install the wheel file.

Error while importing datasets from sklearn

import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn import svm
it gives the following error-
Traceback (most recent call last):
File "/home/songoku/PycharmProjects/untitled/sklearn.py", line 4, in <module>
from sklearn import datasets
File "/home/songoku/PycharmProjects/untitled/sklearn.py", line 4, in <module>
from sklearn import datasets
ImportError: cannot import name 'datasets'
Rename /home/songoku/PycharmProjects/untitled/sklearn.py to something that differs from the SKLearn module name: sklearn.py
Try checking the version of sklearn first. The modules like data-sets and svm is not a part of sklearn packages (0.19 <) i.e less than version number 0.19.0.
You can check this on the command line: pip3 list
it shows you the version of all libraries installed by pip3.
Note: Always double check if you istalled the libraries as a part of anaconda or pip3

Error while importing scikits.talkbox

I want to use scikits.talkbox, but i get the following error while import scikits.talkbox.
Traceback (most recent call last):
File "/home/seref/Desktop/machine learning codes/MFCC/main.py", line 3, in
from scikits.talkbox.features.mfcc import mfcc
File "/usr/local/lib/python3.5/dist-packages/scikits/talkbox/init.py", line 3, in
from tools import *
ImportError: No module named 'tools'
code sample
import scipy.io.wavfile
from scikits.talkbox.features.mfcc import mfcc
sample_rate, X = scipy.io.wavfile.read("data/test_1.wav")
ceps, mspec, spec = mfcc(X)
I use following code when installing scikits.talkbox
sudo pip3 install scikits.talkbox
Operation system ubuntu 16.10
python interpreter 3.5.2+
If you want MFCCs in Python 3, librosa is probably the better library of your choice.

Resources