When I try to launch jupyter notebook, I get this from anaconda prompt
enter image description here
after launching jupyter notebook, I get this on anaconda prompt before jupyter notebook opens in browser
enter image description here
after running the following import code:
import pandas as pd
import numpy as np
import seaborn as sn
from sklearn import datasets
from sklearn import metrics
from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import DecisionTreeRegressor
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
from sklearn.preprocessing import LabelEncoder
from sklearn.tree import export_graphviz
i get the following error:
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_6884\4230379327.py in <module>
4 import pandas as pd
5 import numpy as np
----> 6 import seaborn as sn
7 from sklearn import datasets
8 from sklearn import metrics
~\Anaconda3\lib\site-packages\seaborn\__init__.py in <module>
1 # Import seaborn objects
----> 2 from .rcmod import * # noqa: F401,F403
3 from .utils import * # noqa: F401,F403
4 from .palettes import * # noqa: F401,F403
5 from .relational import * # noqa: F401,F403
~\Anaconda3\lib\site-packages\seaborn\rcmod.py in <module>
5 import matplotlib as mpl
6 from cycler import cycler
----> 7 from . import palettes
8
9
~\Anaconda3\lib\site-packages\seaborn\palettes.py in <module>
7 from .external import husl
8
----> 9 from .utils import desaturate, get_color_cycle
10 from .colors import xkcd_rgb, crayons
11
~\Anaconda3\lib\site-packages\seaborn\utils.py in <module>
11 import pandas as pd
12 import matplotlib as mpl
---> 13 import matplotlib.colors as mplcol
14 import matplotlib.pyplot as plt
15 from matplotlib.cbook import normalize_kwargs
ModuleNotFoundError: No module named 'matplotlib.colors'
when i comment the line giving the above error #import seaborn as sn i get the following error:
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_6884\1207372402.py in <module>
8 from sklearn import metrics
9 from sklearn import tree
---> 10 from sklearn.tree import DecisionTreeClassifier
11 from sklearn.tree import DecisionTreeRegressor
12 from sklearn.model_selection import train_test_split
ImportError: cannot import name 'DecisionTreeClassifier' from 'sklearn.tree' (unknown location)
when I run pip list, it shows that I have both seaborn 0.11.2 and scikitlearn 1.0.2 installed.
what could be wrong and how do i fix this?
Related
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn
from sklearn.model_selection import train_test_split
import statsmodels.api as sm
While running this cell in Jupyter Notebook I am getting the following error:
C:\Anaconda\lib\site-packages\_pytest\_code\__init__.py in <module>
1 """ python inspection/code generation API """
----> 2 from .code import Code # noqa
3 from .code import ExceptionInfo # noqa
4 from .code import filter_traceback # noqa
5 from .code import Frame # noqa
C:\Anaconda\lib\site-packages\_pytest\_code\code.py in <module>
390
391
--> 392 #attr.s(repr=False)
393 class ExceptionInfo(Generic[_E]):
394 """ wraps sys.exc_info() objects and offers
AttributeError: module 'attr' has no attribute 's'
Can somebody explain what is happening?
Enter these commands on the terminal or in a notebook:
pip uninstall attr
pip install attrs
I tried to import statsmodels in python, using
import statsmodels.api as sm
but I failed.
I got an error
cannot import name 'unicode' from 'statsmodels.compat'
I reinstalled and upgraded statsmodels package, but the error remains.
Could you help me to fix this error?
This is my traceback.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-125-085740203b77> in <module>
----> 1 import statsmodels.api as sm
c:\python\python37\lib\site-packages\statsmodels\api.py in <module>
7 from . import regression
8 from .regression.linear_model import OLS, GLS, WLS, GLSAR
----> 9 from .regression.recursive_ls import RecursiveLS
10 from .regression.quantile_regression import QuantReg
11 from .regression.mixed_linear_model import MixedLM
c:\python\python37\lib\site-packages\statsmodels\regression\recursive_ls.py in <module>
10 import pandas as pd
11
---> 12 from statsmodels.compat import unicode
13 from statsmodels.tools.data import _is_using_pandas
14 from statsmodels.tsa.statespace.mlemodel import (
ImportError: cannot import name 'unicode' from 'statsmodels.compat' (c:\python\python37\lib\site-packages\statsmodels\compat\__init__.py)
I use the ColumnTransfomer from Scikit-Learn and it usually works fine. Some days its decides to give me this error?
I have updated scikitlearn and it is on version 0.20. I am using Azure Notebooks (Jupyter Notebooks).
Here is the error that printed when I run:
from sklearn.compose import ColumnTransformer
ImportError Traceback (most recent call last)
<ipython-input-71-95a87d70dcfe> in <module>()
----> 1 from sklearn.compose import ColumnTransformer
~/anaconda3_501/lib/python3.6/site-packages/sklearn/compose/__init__.py in <module>()
6 """
7
----> 8 from ._column_transformer import ColumnTransformer, make_column_transformer
9 from ._target import TransformedTargetRegressor
10
~/anaconda3_501/lib/python3.6/site-packages/sklearn/compose/_column_transformer.py in <module>()
15
16 from ..base import clone, TransformerMixin
---> 17 from ..utils import Parallel, delayed
18 from ..externals import six
19 from ..pipeline import _fit_transform_one, _transform_one, _name_estimators
ImportError: cannot import name 'Parallel'
Thanks!
Vrage
You can import ColumnTransfomer when you are importing numpy in the start of the code. By importing with compose package, it will get solved. I did the same and it worked. Make sure you have installed all the packages properly.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
Here is my basic program I am running with a local jupyter notebook on my computer. I am not sure how to resolve this dll error:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
Here is the error message accompanying my code:
ImportError Traceback (most recent call last)
<ipython-input-1-c1680853bc3a> in <module>()
1 import numpy as np
2 import matplotlib as mpl
----> 3 import matplotlib.pyplot as plt
4 #%matplotlib inline
c:\python27\lib\site-packages\matplotlib\pyplot.py in <module>()
29 from cycler import cycler
30 import matplotlib
---> 31 import matplotlib.colorbar
32 from matplotlib import style
33 from matplotlib import _pylab_helpers, interactive
c:\python27\lib\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
c:\python27\lib\site-packages\matplotlib\artist.py in <module>()
14 import matplotlib
15 from . import cbook, docstring, rcParams
---> 16 from .path import Path
17 from .transforms import (Bbox, IdentityTransform, Transform, TransformedBbox,
18 TransformedPatchPath, TransformedPath)
c:\python27\lib\site-packages\matplotlib\path.py in <module>()
19 import numpy as np
20
---> 21 from . import _path, rcParams
22 from .cbook import (_to_unmasked_float_array, simple_linear_interpolation,
23 maxdict)
ImportError: DLL load failed: %1 is not a valid Win32 application.
This question already has answers here:
import pandas_datareader gives ImportError: cannot import name 'is_list_like'
(6 answers)
Closed 4 years ago.
I am trying to run the following code using pandas_datareader on PYTHON 3.6.5 IDLE(WIN 10 SYS).
#import our Python libraries
import os
import sys
import pandas as pd
import pandas_datareader.data as web
import numpy as np
import statsmodels.formula.api as smf
import statsmodels.tsa.api as smt #tsa为Time Series analysis缩写
import statsmodels.api as sm
import scipy.stats as scs
from arch import arch_model
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline
It seems work on IDE eclipse, but when I try to run it on jupyter notebook, although i have installed the pandas_datareader package, jupyter continues
to stop with the following errors. I have checked that it is not concerned with any circular references or any file name conflicts.Why does it happen?
ImportError Traceback (most recent call last)
<ipython-input-4-4b149e7cab54> in <module>()
4
5 import pandas as pd
----> 6 import pandas_datareader.data as web
7 import numpy as np
8
d:\programs\python\python36\lib\site-packages\pandas_datareader\__init__.py in <module>()
1 from ._version import get_versions
----> 2 from .data import (DataReader, Options, get_components_yahoo,
3 get_dailysummary_iex, get_data_enigma, get_data_famafrench,
4 get_data_fred, get_data_google, get_data_moex,
5 get_data_morningstar, get_data_quandl, get_data_stooq,
d:\programs\python\python36\lib\site-packages\pandas_datareader\data.py in <module>()
12 ImmediateDeprecationError
13 from pandas_datareader.famafrench import FamaFrenchReader
---> 14 from pandas_datareader.fred import FredReader
15 from pandas_datareader.google.daily import GoogleDailyReader
16 from pandas_datareader.google.options import Options as GoogleOptions
d:\programs\python\python36\lib\site-packages\pandas_datareader\fred.py in <module>()
----> 1 from pandas.core.common import is_list_like
2 from pandas import concat, read_csv
3
4 from pandas_datareader.base import _BaseReader
5
ImportError: cannot import name 'is_list_like'
This is a known issue of pandas-datareader and will be fixed on release 0.7.0 as stated here.
For now, you could try to use the development version based on its master branch.