I'm trying to import pandas and I'm facing some issues
import numpy as np
import multiprocessing as mp
import pandas as pd
result:
C:\Anaconda\lib\site-packages\pandas\core\indexes\base.py in <module>
57 import pandas.core.sorting as sorting
58 from pandas.io.formats.printing import pprint_thing
---> 59 from pandas.core.ops import _comp_method_OBJECT_ARRAY
60 from pandas.core import strings, accessor
61 from pandas.core.config import get_option
ImportError: cannot import name 'ops'
OR
AttributeError: module 'pandas' has no attribute 'core'
Please try the following step and restart the jupyter notebook:
conda upgrade --all
If it is still showing the same error, try downgrading the pandas version:
pip install pandas==0.22.0
Hope this helps.
Related
I'm trying to import the xarray module into python 3.8.10 but I get this error:
AttributeError: module 'numpy.random' has no attribute 'BitGenerator'
In order to allow you to reproduce the error: First of all, I created a new environment with conda and by importing at the same time the modules I need (to avoid the problems of incompatible dependencies) :
conda create -n Myenv Python=3.8 matplotlib numpy time xarray netCDF4 termcolor
Then, I try to import in ipython3 all modules I need to run my code:
import matplotlib as mpl
mpl.use('agg')
import numpy as np
import os
import time
import glob
import sys
from datetime import datetime,date,timedelta
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
import matplotlib.colors as colors
# from operator import itemgetter
from netCDF4 import Dataset
from mpl_toolkits.basemap import Basemap, shiftgrid
from termcolor import colored
import xarray as xr
and, at this moment, I get the error...
I searched the documentation to see if the BitGenerator Attribute exists in my version of numpy (1.22.3), and it does. So I don't understand why this error occurs.
Someone can help me to understand please ?
Thank u !
If you want more informations about my environnement, I can provide.
I solved mine with pip install --upgrade numpy
i have read all the posts related to this topic but i could not find the solution for my case.
In my ubuntu 20.04 I have installed plotly through the command:
pip3 install plotly
and if i launch python3 from command line and if i run:
import plotly.graph_objects as go
it works perfectly. But if i launch the same command from python script "test.py":
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import cgi
import cgitb
from datetime import date, timedelta
import datetime
import time
import numpy as np
import pandas as pd
import os
import calendar
import matplotlib
matplotlib.use('Agg')
import matplotlib.pylab as plt
import plotly.graph_objects as go
it returns the error log:
ModuleNotFoundError: No module named 'plotly'
Anyone can help me? many thanks
Ok, i resolved the issue by installing the module as a root user because in this way Python will try to search for the module’s name in the root directory and not in the usr one
thank you everyone
I have been struggling for several hours to import keras and tensorflow, but I am unable to import them.
import os
import random
import sys
# Package
import glob
import tensorflow as tf
import keras
import IPython.display as ipd
import librosa
import librosa.display
import matplotlib.pyplot as plt
import numpy as np
Also, when I try to import something, I am unable to do that. Could someone help me out ?
Thank you !
These are the errors I got:
Original exception was:
Traceback (most recent call last):
File "/home/vlad/speech_recognition/emotionrecognition.py", line 8, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
I tried to import cufflinks, with this code :
from textblob import TextBlob
from wordcloud import WordCloud, STOPWORDS
import chart_studio.plotly as py
import plotly.graph_objs as go
from plotly.offline import iplot
import cufflinks
cufflinks.go_offline()
cufflinks.set_config_file(world_readable=True, theme='pearl', offline=True)
but it returns an error like this:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-4cccab8ca8ac> in <module>
5 import plotly.graph_objs as go
6 from plotly.offline import iplot
----> 7 import cufflinks
8 cufflinks.go_offline()
9 cufflinks.set_config_file(world_readable=True, theme='pearl', offline=True)
~\Anaconda3\lib\site-packages\cufflinks\__init__.py in <module>
17
18 from .plotlytools import *
---> 19 from plotly.plotly import plot
20 from .colors import cnames, get_colorscale
21 from .utils import pp
ImportError: cannot import name 'plot' from 'plotly.plotly' (C:\Users\asus\Anaconda3\lib\site-packages\plotly\plotly\__init__.py)
At first, it was an error at import plotly.plotly as py code that said the plotly was deprecated, and recommend me to use chart_studio.plotly.
So, I change the code and it works, but the import cufflinks is still error. Can anyone help me?
This solution is from an opened issue from cufflinks source code page. Basically, your Jupyter Notebook is throwing an error because the source code hasn't been updated even after installing chart_studio.
To fix this problem, go to the directory that contains cufflinks source code. In your case it would be \Anaconda3\lib\site-packages\cufflinks. Within that directory, locate three files, namely: _init_.py, plotlytools.py, and tools.py. In each of the respective files, change "plotly.plotly" to "chart_studio.plotly" and save the file.
Try running the import again.
This post from plotly community might be helpful as well! Do note that this post actually redirects you to the original opened issue.
If you're familiar with Github PRs, these are the proposed commits (hasn't been merged yet though..)
import pandas as pd
import numpy as np
import sklearn
from scipy import stats
import matplotlib.pyplot as plt
import os
import seaborn as sns
sns.set(); np.random.seed(0)
x = np.random.randn(100)
sns.distplot(x)
I just copy the example from the documention,but I get such error,I have try to change the enviroment such in shell to run it .But fail too.
Traceback (most recent call last):
File "/Users/Betterwittyman/Desktop/job_25/别人的/pdf_model2.py", line 13, in <module>
sns.distplot(x)
TypeError: slice indices must be integers or None or have an __index__ method
Can you tell me the numpy and statsmodel version that you use ?
You can try the following:
1) Update the statsmodel package using
pip install -U statsmodels
2) can you try to run the following and let me if it works?
sns.distplot(x, bins=50, kde=False)
plt.show()
P.S: your code works for me using: numpy: 1.11.3, scipy: 0.18.1, statsmodels: 0.6.1
May be the version is not up to date.so follow the below command it worked.
sudo pip install --upgrade seaborn
This may solve your error:
import pandas as pd
import numpy as np
import sklearn
from scipy import stats
import matplotlib.pyplot as plt
import os
import seaborn as sns
sns.set()
np.random.seed(0)
x = np.random.randn(100)
sns.distplot(x)