简体   繁体   English

python3.6中导入matplotlib的问题

[英]problems with import matplotlib in python3.6

I'm trying to learn a project related to road_lane_line_detection. 我正在尝试学习与road_lane_line_detection相关的项目。 However, other dependencies except "matplotlib" have already installed successfully, include: numpy, opencv-python, moviepy. 但是,除“ matplotlib”之外的其他依赖项已经成功安装,包括: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. matplotlib使用一个名为matplotlibrc的文件来存储配置默认值。 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. 该错误告诉您/Users/Ford/.matplotlib/matplotlibrc确实存在,但是它是目录而不是文件,这使安装脚本感到困惑。

You can probably fix this problem by removing the matplotlibrc directory, but be careful that there aren't any important files in there. 您可以通过删除matplotlibrc目录来解决此问题,但请注意其中没有任何重要文件。 To be safe, you could rename it to something else: 为了安全起见,您可以将其重命名为其他名称:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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