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.
Related
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?
I really need some help, as I have gone through all the posts and nothing has worked. I get this error when importing gensim and not numpy (numpy is before and works fine). All I want to do is import gensim and numpy to then run my analysis.
Here is the full error message:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-3f0b98039a34> in <module>()
1 # pip install --user numpy==1.16.4
2
----> 3 import gensim
4 #import numpy
5
~/.local/lib64/python3.6/site-packages/gensim/__init__.py in <module>()
9 import logging
10
---> 11 from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401
12
13
~/.local/lib64/python3.6/site-packages/gensim/corpora/__init__.py in <module>()
4
5 # bring corpus classes directly into package namespace, to save some typing
----> 6 from .indexedcorpus import IndexedCorpus # noqa:F401 must appear before the other classes
7
8 from .mmcorpus import MmCorpus # noqa:F401
~/.local/lib64/python3.6/site-packages/gensim/corpora/indexedcorpus.py in <module>()
12 import numpy
13
---> 14 from gensim import interfaces, utils
15
16 logger = logging.getLogger(__name__)
~/.local/lib64/python3.6/site-packages/gensim/interfaces.py in <module>()
17 import logging
18
---> 19 from gensim import utils, matutils
20
21
~/.local/lib64/python3.6/site-packages/gensim/matutils.py in <module>()
17 import numpy as np
18 import scipy.sparse
---> 19 from scipy.stats import entropy
20 import scipy.linalg
21 from scipy.linalg.lapack import get_lapack_funcs
/cluster/apps/python/3.6.4_cpu/lib64/python3.6/site-packages/scipy/stats/__init__.py in <module>()
343 from .stats import *
344 from .distributions import *
--> 345 from .morestats import *
346 from ._binned_statistic import *
347 from .kde import gaussian_kde
/cluster/apps/python/3.6.4_cpu/lib64/python3.6/site-packages/scipy/stats/morestats.py in <module>()
10 sqrt, ceil, floor, array, compress,
11 pi, exp, ravel, count_nonzero, sin, cos, arctan2, hypot)
---> 12 from numpy.testing.decorators import setastest
13
14 from scipy._lib.six import string_types
ModuleNotFoundError: No module named 'numpy.testing.decorators'
What I have tried:
I have tried using the latest version of numpy, and also forcing it to the version 1.16.4 "pip install --user numpy==1.16.4". I have also tried uninstalling and reinstalling both gensim and numpy, but its not working. I am using Python 3.6 and on a cluster. I don't really understand why numpy has no problem being imported, but that this is a problem of gensim.
Can anyone kindly help me out with this?
Thanks a lot!
Best,
Sandra
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.
Cannot import matplotlib with ipython/jupyter notebook through a virtual environment.
I'm able to import matplotlib just fine using the console. Having seen other SO posts I can't seem to get this set up right.
I followed this to get the separate ipython/jupyter kernel.
When I checked my locations through jupyter I get
six.__file__: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc'
and
datutil.__file__: '/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
I am not sure these are correct. Main jupyter error below
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-20188fbdb2fd> in <module>()
1
----> 2 import matplotlib.pyplot as plt
3 get_ipython().magic(u'matplotlib inline')
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py in <module>()
27 from matplotlib import docstring
28 from matplotlib.backend_bases import FigureCanvasBase
---> 29 from matplotlib.figure import Figure, figaspect
30 from matplotlib.gridspec import GridSpec
31 from matplotlib.image import imread as _imread
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/figure.py in <module>()
34 import matplotlib.colorbar as cbar
35
---> 36 from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
37 from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput
38 from matplotlib.legend import Legend
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py in <module>()
18 import matplotlib.colors as mcolors
19 import matplotlib.contour as mcontour
---> 20 import matplotlib.dates as _ # <-registers a date unit converter
21 from matplotlib import docstring
22 import matplotlib.font_manager as font_manager
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/dates.py in <module>()
117
118
--> 119 from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
120 MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
121 SECONDLY)
/Library/Python/2.7/site-packages/dateutil/rrule.py in <module>()
17
18 from six import advance_iterator, integer_types
---> 19 from six.moves import _thread
20 import heapq
21
ImportError: cannot import name _thread
Ok I fixed this by using the tutorial properly (http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs)
You need to set up a virtualenv, then make sure that you install jupyter within it. I was using the globally installed jupyter.
Then set up the new jupyter kernel (linked above) and everything should work with your virtualenv pointed to correctly
Although this has come up as a topic before it has not been answered. I get the following import error I have just installed canopy from EPD and after I installed it, it keeps coming up with the following error:
IPython 2.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] WARNING | Eventloop or matplotlib integration failed. Is matplotlib installed?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/IPython/core/shellapp.pyc in <lambda>(key)
231 shell = self.shell
232 if self.pylab:
--> 233 enable = lambda key: shell.enable_pylab(key, import_all=self.pylab_import_all)
234 key = self.pylab
235 elif self.matplotlib:
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_pylab(self, gui, import_all, welcome_message)
2980 from IPython.core.pylabtools import import_pylab
2981
-> 2982 gui, backend = self.enable_matplotlib(gui)
2983
2984 # We want to prevent the loading of pylab to pollute the user's
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
2941 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
2942
-> 2943 pt.activate_matplotlib(backend)
2944 pt.configure_inline_support(self, backend)
2945
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in activate_matplotlib(backend)
285 matplotlib.rcParams['backend'] = backend
286
--> 287 import matplotlib.pyplot
288 matplotlib.pyplot.switch_backend(backend)
289
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
22
23 import matplotlib
---> 24 import matplotlib.colorbar
25 from matplotlib import _pylab_helpers, interactive
26 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
27 import matplotlib.artist as martist
28 import matplotlib.cbook as cbook
---> 29 import matplotlib.collections as collections
30 import matplotlib.colors as colors
31 import matplotlib.contour as contour
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/matplotlib/collections.py in <module>()
21 import matplotlib.artist as artist
22 from matplotlib.artist import allow_rasterization
---> 23 import matplotlib.backend_bases as backend_bases
24 import matplotlib.path as mpath
25 from matplotlib import _path
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/matplotlib/backend_bases.py in <module>()
48
49 import matplotlib.tight_bbox as tight_bbox
---> 50 import matplotlib.textpath as textpath
51 from matplotlib.path import Path
52 from matplotlib.cbook import mplDeprecation
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/matplotlib/textpath.py in <module>()
9 from matplotlib.path import Path
10 from matplotlib import rcParams
---> 11 import matplotlib.font_manager as font_manager
12 from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
13 from matplotlib.ft2font import LOAD_TARGET_LIGHT
/home/rhys/Documents/Uni_work/Year_2_research_placement/User/lib/python2.7/site-packages/matplotlib/font_manager.py in <module>()
51 import matplotlib
52 from matplotlib import afm
---> 53 from matplotlib import ft2font
54 from matplotlib import rcParams, get_cachedir
55 from matplotlib.cbook import is_string_like
ImportError: libpng16.so.16: cannot open shared object file: No such file or directory
I have tried reinstalling matplotlib but it still comes up with the error and I cannot find the libpng16.so.16 file in \usr\local\lib, can anyone help?
Check Canopy's Package Manager. Make sure matplotlib 1.3.1-8 package is installed.
An older version of matplotlib could be installed. Check the updates section and update your canopy.