AttributeError: модуль 'matplotlib.cbook' не имеет атрибута '_rename_parameter' - PullRequest
0 голосов
/ 20 апреля 2020

Хай, я взял курс edx по компьютерному зрению, они предоставили ноутбуки python, чтобы клонировать их на

azure учетную запись службы в сети

при выполнении ячеек. получил следующую ошибку, может кто-нибудь помочь мне с этим

import os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import image as mp_image
# Required magic to display matplotlib plots in notebooks
%matplotlib inline

src_folder = "../data/voc"

# Set up a figure of an appropriate size
fig = plt.figure(figsize=(12, 12))

# loop through the subfolders
for root, folders, filenames in os.walk(src_folder):
     image_num = 0
     num_folders = len(folders)
     for folder in sorted(folders):
          # Keep an incrementing count of each image
          image_num +=1
          # Find the first image file in the folder
          file_name = os.listdir(os.path.join(root,folder))[0]
          # Get the full path from the root folder
          file_path = os.path.join(root,folder, file_name)
          # Open the file using the matplotlib.image library
          image = mp_image.imread(file_path)
          # Add the image to the figure (which will have a row for each folder, each containing one 
          column for the image)
          a=fig.add_subplot(num_folders, 1, image_num)
          # Add the image to the plot
          image_plot = plt.imshow(image)
          # Add a caption with the folder name
          a.set_title(folder)

 # Show the plot
 plt.show()

Выход ячейки

/ home / nbuser / anaconda3_501 / lib / python3 .6 / site-packages / matplotlib / font_manager.py: 229: UserWarning: Matplotlib создает кэш шрифтов, используя список f c. Это может занять некоторое время.

'Matplotlib создает кэш шрифтов с помощью списка f c. '

!pip install opencv-python
!pip install --upgrade scikit-image

установленных пакетов

from PIL import Image
import skimage as sk
from skimage import io as sk_io
import cv2

images = []

pil_image = Image.open(os.path.join(src_folder, "automobile", "000522.jpg"))
images.append(pil_image)
sk_image = sk_io.imread(os.path.join(src_folder, "plane", "000228.jpg"))
images.append(sk_image)
cv_image = cv2.imread(os.path.join(src_folder, "train", "000712.jpg"))
images.append(cv_image)

# Set up a figure of an appropriate size
fig = plt.figure(figsize=(12, 12))

image_num = 0
num_images = len(images)
# loop through the images
for image_idx in range(num_images):
    # Keep an incrementing count of each image
    a=fig.add_subplot(1, num_images, image_idx+1)
    # Add the image to the plot
    image_plot = plt.imshow(images[image_idx])
    # Add a caption with the folder name
    a.set_title("Image " + str(image_idx+1))

# Show the plot
plt.show()

Ouput получил следующую ошибку

AttributeError   Traceback (most recent call last)

<ipython-input-4-dbb66d7164ab> in <module>

            1 from PIL import Image

            2 import skimage as sk

      ----> 3 from skimage import io as sk_io

            4 import cv2

            5 

~/anaconda3_501/lib/python3.6/site-packages/skimage/io/__init__.py in <module>

            13 

            14 

       ---> 15 reset_plugins()

            16 

            17 WRAP_LEN = 73

~/anaconda3_501/lib/python3.6/site-packages/skimage/io/manage_plugins.py in reset_plugins()

            89 def reset_plugins():
            90     _clear_plugins()
       ---> 91     _load_preferred_plugins()
            92 
            93 

~/anaconda3_501/lib/python3.6/site-packages/skimage/io/manage_plugins.py in _load_preferred_plugins()

            69                 'imread']
            70     for p_type in io_types:
       ---> 71         _set_plugin(p_type, preferred_plugins['all'])
            72 
            73     plugin_types = (p for p in preferred_plugins.keys() if p != 'all')

~/anaconda3_501/lib/python3.6/site-packages/skimage/io/manage_plugins.py in _set_plugin(plugin_type, 
plugin_list)

            81             continue
            82         try:
       ---> 83             use_plugin(plugin, kind=plugin_type)
            84             break
            85         except (ImportError, RuntimeError, OSError):

~/anaconda3_501/lib/python3.6/site-packages/skimage/io/manage_plugins.py in use_plugin(name, kind)

            252             kind = [kind]
            253 
        --> 254     _load(name)
            255 
            256     for k in kind:

~/anaconda3_501/lib/python3.6/site-packages/skimage/io/manage_plugins.py in _load(plugin)

296         modname = plugin_module_name[plugin]
297         plugin_module = __import__('skimage.io._plugins.' + modname,
--> 298                                    fromlist=[modname])
299 
300     provides = plugin_provides[plugin]

~/anaconda3_501/lib/python3.6/site-packages/skimage/io/_plugins/matplotlib_plugin.py in <module>
  1 from collections import namedtuple
  2 import numpy as np
----> 3 from mpl_toolkits.axes_grid1 import make_axes_locatable
  4 import matplotlib.image
  5 from ...util import dtype as dtypes

~/anaconda3_501/lib/python3.6/site-packages/mpl_toolkits/axes_grid1/__init__.py in <module>
  1 from . import axes_size as Size
  2 from .axes_divider import Divider, SubplotDivider, make_axes_locatable
----> 3 from .axes_grid import Grid, ImageGrid, AxesGrid
  4 
  5 from .parasite_axes import host_subplot, host_axes

~/anaconda3_501/lib/python3.6/site-packages/mpl_toolkits/axes_grid1/axes_grid.py in <module>
 30 
 31 
---> 32 class CbarAxesBase:
 33 
 34     @cbook._rename_parameter("3.2", "locator", "ticks")

~/anaconda3_501/lib/python3.6/site-packages/mpl_toolkits/axes_grid1/axes_grid.py in CbarAxesBase()
 32 class CbarAxesBase:
 33 
---> 34     @cbook._rename_parameter("3.2", "locator", "ticks")
 35     def colorbar(self, mappable, *, ticks=None, **kwargs):
 36 

AttributeError: module 'matplotlib.cbook' has no attribute '_rename_parameter'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...