簡體   English   中英

無法在Jupyter Notebook中導入軟件包

[英]cannot import packages in jupyter notebook

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
from glob import glob
import seaborn as sns
from PIL import Image
np.random.seed(123)
from sklearn.preprocessing import label_binarize
from sklearn.metrics import confusion_matrix
import itertools

import keras
from keras.utils.np_utils import to_categorical # used for converting labels to one-hot-encoding
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D
from keras import backend as K
import itertools
from keras.layers.normalization import BatchNormalization
from keras.utils.np_utils import to_categorical # convert to one-hot-encoding

from keras.optimizers import Adam
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import ReduceLROnPlateau
from sklearn.model_selection import train_test_split

當我將tensorflow下載到anaconda時出現錯誤,我不知道為什么會出現此錯誤可以有人幫助我,因為我是anaconda的新手,此代碼是從kaggle復制的,其鏈接是https://www.kaggle.com/sid321axn/步驟明智的方法CNN模型77-0344-准確性,但我不知道為什么我面臨此錯誤

ImportError                               Traceback (most recent call last)
<ipython-input-1-36803f80ec4f> in <module>
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
      2 import matplotlib.pyplot as plt
      3 import numpy as np
      4 import pandas as pd
      5 import os

~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2285                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2286             with self.builtin_trap:
-> 2287                 result = fn(*args,**kwargs)
   2288             return result
   2289 

<decorator-gen-108> in matplotlib(self, line)

~\Anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~\Anaconda3\lib\site-packages\IPython\core\magics\pylab.py in matplotlib(self, line)
     97             print("Available matplotlib backends: %s" % backends_list)
     98         else:
---> 99             gui, backend = self.shell.enable_matplotlib(args.gui)
    100             self._show_matplotlib_backend(args.gui, backend)
    101 

~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in enable_matplotlib(self, gui)
   3353                 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
   3354 
-> 3355         pt.activate_matplotlib(backend)
   3356         pt.configure_inline_support(self, backend)
   3357 

~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in activate_matplotlib(backend)
    311     matplotlib.rcParams['backend'] = backend
    312 
--> 313     import matplotlib.pyplot
    314     matplotlib.pyplot.switch_backend(backend)
    315 

~\Anaconda3\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

~\Anaconda3\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

~\Anaconda3\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)

~\Anaconda3\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: cannot import name '_path'

檢查您的環境。 該代碼工作正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM