简体   繁体   中英

problems with import matplotlib in python3.6

I'm trying to learn a project related to road_lane_line_detection. However, other dependencies except "matplotlib" have already installed successfully, include: numpy, opencv-python, moviepy.

here is the recording:

(hqs0) ForddeMacBook-Pro:~ Ford$ pip install matplotlib
Requirement already satisfied: matplotlib in ./hqs0/lib/python3.6/site-packages
Requirement already satisfied: cycler>=0.10 in ./hqs0/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: python-dateutil in ./hqs0/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pyparsing!=2.0.0,!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in ./hqs0/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pytz in ./hqs0/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: numpy>=1.7.1 in ./hqs0/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: six>=1.10 in ./hqs0/lib/python3.6/site-packages (from matplotlib)
(hqs0) ForddeMacBook-Pro:~ Ford$ python
Python 3.6.1 (default, Apr  4 2017, 09:36:47) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import cv2
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Ford/hqs0/lib/python3.6/site-packages/matplotlib/__init__.py", line 1182, in <module>
    rcParams = rc_params()
  File "/Users/Ford/hqs0/lib/python3.6/site-packages/matplotlib/__init__.py", line 1025, in rc_params
    return rc_params_from_file(fname, fail_on_error)
  File "/Users/Ford/hqs0/lib/python3.6/site-packages/matplotlib/__init__.py", line 1151, in rc_params_from_file
    config_from_file = _rc_params_in_file(fname, fail_on_error)
  File "/Users/Ford/hqs0/lib/python3.6/site-packages/matplotlib/__init__.py", line 1068, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 82, in __enter__
    return next(self.gen)
  File "/Users/Ford/hqs0/lib/python3.6/site-packages/matplotlib/__init__.py", line 1053, in _open_file_or_url
    with io.open(fname, encoding=encoding) as f:
IsADirectoryError: [Errno 21] Is a directory: '/Users/Ford/.matplotlib/matplotlibrc'
>>> 

I am not sure why it cause this problem, and thanks for your help or advice.

matplotlib uses a file called matplotlibrc to store configuration defaults. If this file exists, then the setup script will try to read it. The error is telling you that /Users/Ford/.matplotlib/matplotlibrc does exist, but is a directory rather than a file, which is confusing the setup script.

You can probably fix this problem by removing the matplotlibrc directory, but be careful that there aren't any important files in there. To be safe, you could rename it to something else:

mv /Users/Ford/.matplotlib/matplotlibrc /Users/Ford/.matplotlib/matploblirc_old

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM