I am facing this issue in seaborn import: - python

When I try running following line in Jupiter notebook
> import seaborn as sns
I get this error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-ed9806ce3570> in <module>()
----> 1 import seaborn as sns
~/anaconda3/lib/python3.6/site-packages/seaborn/__init__.py in <module>()
8 from .palettes import *
9 from .regression import *
---> 10 from .categorical import *
11 from .distributions import *
12 from .timeseries import *
~/anaconda3/lib/python3.6/site-packages/seaborn/categorical.py in <module>()
5 from scipy import stats
6 import pandas as pd
----> 7 from pandas.core.series import remove_na
8 import matplotlib as mpl
9 from matplotlib.collections import PatchCollection
ImportError: cannot import name 'remove_na'
dependency versions are listed below:
Python 3.6.3
conda 4.8.2
numpy 1.18.0
pandas 1.0.1
scipy 1.1.0
matplotlib 3.1.3
What is the issue here?

Okay,
so I still dont know, what was wrong in this, but I did solve the problem.
I simply uninstalled seaborn
pip3 uninstall seaborn
and installed it again
pip3 install seaborn
it worked, no error this time.
But I still dont know, what went wrong first time.
If someone can help please share.

The problem is that seaborn seems to be using a private method from pandas. The issue has been reported to both pandas and seaborn developers (see https://github.com/pandas-dev/pandas/issues/16971 and https://github.com/mwaskom/seaborn/pull/1241) which both published a fix in later versions.
The fixed version is available on pip but not on Ubuntu's packages yet (as of August 2020).
However, for those who don't want pip install, the fix is straightforward and can be manually applied (see the pull request above).

Related

Top2Vec import fails due to problems with numpy version conflicts

I'm facing an issue which seems to occur very often but the solutions I found so far did not helped me. When I try to do from top2vec import Top2Vec I get the following error:
ValueError Traceback (most recent call last)
<ipython-input-14-f6d7059c0d66> in <module>
----> 1 from top2vec import Top2Vec
2 model = Top2Vec(documents=data, speed="learn", workers=8)
~/env_env/lib/python3.7/site-packages/top2vec/__init__.py in <module>
----> 1 from top2vec.Top2Vec import Top2Vec
2
3 __version__ = '1.0.26'
~/env_env/lib/python3.7/site-packages/top2vec/Top2Vec.py in <module>
9 from gensim.parsing.preprocessing import strip_tags
10 import umap
---> 11 import hdbscan
12 from wordcloud import WordCloud
13 import matplotlib.pyplot as plt
~/env_env/lib/python3.7/site-packages/hdbscan/__init__.py in <module>
----> 1 from .hdbscan_ import HDBSCAN, hdbscan
2 from .robust_single_linkage_ import RobustSingleLinkage, robust_single_linkage
3 from .validity import validity_index
4 from .prediction import (approximate_predict,
5 membership_vector,
~/env_env/lib/python3.7/site-packages/hdbscan/hdbscan_.py in <module>
19 from scipy.sparse import csgraph
20
---> 21 from ._hdbscan_linkage import (single_linkage,
22 mst_linkage_core,
23 mst_linkage_core_vector,
hdbscan/_hdbscan_linkage.pyx in init hdbscan._hdbscan_linkage()
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
When I try to upgrade to numpy==1.20.0 like other solutions suggest than I get in trouble with other packages I need (as displayed in the ERROR warnings below)
ERROR: transformers 4.9.1 has requirement huggingface-hub==0.0.12, but you'll have huggingface-hub 0.0.15 which is incompatible.
ERROR: flair 0.8.0.post1 has requirement numpy<1.20.0, but you'll have numpy 1.20.0 which is incompatible.de here
Does anyone has an idea how to work around on this or was facing the similar issue? I would appreciate every kind of hint!!! Thanks in advance!
I have faced the same issue. I Just installed top2vec==1.0.20 this version of Top2Vec using pip, without upgrading Numpy, and also it required joblib library too.
So install both.

No module named hyppo._utils when importing models

My issue is when trying to import the DCSBM model:
Code:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import hyppo
from hyppo.time_series import _utils as _utils
from graspy.embed import AdjacencySpectralEmbed
from graspy.models import DCSBMEstimator
from graspy.models import EREstimator
from graspy.models import SBMEstimator
from graspy.models.sbm import _block_to_full, _get_block_indices
from graspy.simulations import er_np, sbm
Error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-33-287386449480> in <module>()
8 from hyppo.time_series import _utils as _utils
9 from graspy.embed import AdjacencySpectralEmbed
---> 10 from graspy.models import DCSBMEstimator
11 from graspy.models import EREstimator
12 from graspy.models import SBMEstimator
2 frames
/usr/local/lib/python3.7/dist-packages/graspy/inference/latent_distribution_test.py in <module>()
26 from sklearn.metrics.pairwise import PAIRWISE_KERNEL_FUNCTIONS
27 from hyppo.ksample import KSample
---> 28 from hyppo._utils import gaussian
29
30 _VALID_DISTANCES = list(PAIRED_DISTANCES.keys())
ModuleNotFoundError: No module named 'hyppo._utils'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
I think hyppo._utils doesn't exist and has been replaced by hyppo.time_series and inside that folder there exists the required _utils package.
How do we fix this?
I was just trying to run the tutorial: https://docs.neurodata.io/notebooks/pedigo/graspologic/2020/09/24/latent_model_tutorial.html
Run on Google colab
This line
from hyppo.time_series import _utils as _utils was added from me trying to fix the issue, but doesn't work.
Looks like you're using an old version of the package - it's called "graspologic" now. If you pip install graspologic, from graspologic.models import DCSBMEstimator should work fine. Just replace everything in that code that says "graspy" with "graspologic".
we're happy to answer questions on github issues as well! (I'm one of the people who contributes to the package)

iPython, Jupyter -> AttributeError: 'module' object has no attribute 'cbook'

I am a beginner at programming and I am working on an online course which uses ipython and jupyter notebook. I am working with Mac OS 10.13.3.
I have tried importing matplotlib as follows,
import matplotlib.pyplot as plt
%matplotlib inline
However, the following error is being generated.
--------------------------
Traceback (most recent call last) <ipython-input-30-385145dcc870> in <module>()
----> 1 import matplotlib.pyplot as plt
2 get_ipython().magic(u'matplotlib inline')
/Users/Varshil/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
27 from cycler import cycler
28 import matplotlib
---> 29 import matplotlib.colorbar
30 from matplotlib import style
31 from matplotlib import _pylab_helpers, interactive
/Users/Varshil/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
30
31 import matplotlib as mpl
---> 32 import matplotlib.artist as martist
33 import matplotlib.cbook as cbook
34 import matplotlib.collections as collections
/Users/Varshil/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/artist.py in <module>()
9 import numpy as np
10 import matplotlib
---> 11 import matplotlib.cbook as cbook
12 from matplotlib.cbook import mplDeprecation
13 from matplotlib import docstring, rcParams
AttributeError: 'module' object has no attribute 'cbook'
It would be of great help if someone could help me solve this issue. I have tried looking up online but have found no successful leads.
This is because you are using old version of matplotlib.
Those who are using GraphLab Create, first activate virtual environment:
source gl-env/bin/activate
Now upgrade matplotlib:
pip install -U matplotlib
Output:
Found existing installation: matplotlib 1.5.1
Uninstalling matplotlib-1.5.1:
Successfully uninstalled matplotlib-1.5.1
Successfully installed matplotlib-2.1.2
Restart iPython/Jupyter.
If you are on Mac, you might get the following error:
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework.
Create a file ~/.matplotlib/matplotlibrc there and add the following code: backend: TkAgg
Again restart iPython/Jupyter.

IPython fails to import Geopandas

After successfully installing the Geopandas conda package from the conda-forge as follows:
conda install -c conda-forge geopandas
When I try to import it in IPython (Jupyter notebook), using:
import geopandas as gpd
I consistently receive the following error, despite having all the dependencies (numpy, pandas, shapely, fiona, six, pyproj) installed and up-to-date:
---------------------------------------------------------------------
------
ImportError Traceback (most recent call
last)
<ipython-input-1-13760ce748ee> in <module>()
4 import matplotlib.mlab as mlab
5
----> 6 import geopandas as gpd
7 import seaborn as sns
8 from sklearn import preprocessing
//anaconda/lib/python2.7/site-packages/geopandas/__init__.py in <module>()
----> 1 from geopandas.geoseries import GeoSeries
2 from geopandas.geodataframe import GeoDataFrame
3
4 from geopandas.io.file import read_file
5 from geopandas.io.sql import read_postgis
//anaconda/lib/python2.7/site-packages/geopandas/geoseries.py in <module>()
6 from pandas import Series, DataFrame
7 from pandas.core.indexing import _NDFrameIndexer
----> 8 from pandas.util.decorators import cache_readonly
9 import pyproj
10 from shapely.geometry import box, shape, Polygon, Point
ImportError: No module named decorators
Any suggestions on what might be causing the error?
To make the comment of Jeff stand out more, this was fixed in pandas 0.20.1.
So normally, if you now install the latest pandas version (not 0.20.0), you should not get this error.

ImportError: cannot import name murmurhash3_32

I am trying to use the sklearn.qda package in python. I have installed it successfully but when Itry to import it I get the error message below. Can anybody tell me what should I do to fix this?
In [3]: from sklearn.qda import QDA
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-7d7abf937d66> in <module>()
----> 1 from sklearn.qda import QDA
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/qda.py in <module>()
12
13 from .base import BaseEstimator, ClassifierMixin
---> 14 from .utils.fixes import unique
15 from .utils import check_arrays, array2d
16
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/__init__.py in <module>()
7 import warnings
8
----> 9 from .murmurhash import murmurhash3_32
10 from .validation import (as_float_array, check_arrays, safe_asarray,
11 assert_all_finite, array2d, atleast2d_or_csc,
ImportError: cannot import name murmurhash3_32
I had the same problem, I run:
sudo pip install -U scikit-learn
and now everything is working fine
I started a new shell and this problem went away
I faced the similar situation of getting mumurhash error while installing sklearn.preprocessing library.
I upgraded numpy version from 1.13 to 1.15
using
pip install --upgrade numpy
After this, I was able to import the sklearn library.
I fixed this by upgrading murmurhash to 1.0.5.
I faced a similar problem, so there are mainly two solutions
Either run it in administrator mode and install all the libraries and run in admin mode. Something that I would not recommend
Use virtualenv to install the libraries again and run your command in the virtualenv. This worked for me.
Hope this helps

Categories

Resources