简体   繁体   English

如何正确安装和导入 matplotlib?

[英]How do I properly instal and import matplotlib?

I'm facing an issue while trying to import matplotlib 3.3.1.我在尝试导入 matplotlib 3.3.1 时遇到问题。 I'm using PyCharm which give me the following error :我正在使用 PyCharm,它给了我以下错误:

Traceback (most recent call last):

  File "<input>", line 1, in <module>

  File "Y:\7-Python\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs)

  File "C:\Users\MMK\Miniconda3\envs\env1\lib\site-packages\matplotlib\__init__.py", line 174, in <module> _check_versions()

  File "C:\Users\MMK\Miniconda3\envs\env1\lib\site-packages\matplotlib\__init__.py", line 159, in _check_versions from . import ft2font

  File "Y:\7-Python\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs)

ImportError: DLL load failed while importing ft2font: Le module spécifié est introuvable.

I've been looking on many topics with the same issue about ft2front but none of them gave me a solution that worked.我一直在寻找许多关于 ft2front 的相同问题的主题,但没有一个给我一个有效的解决方案。 None of them were exactly the same, line error were different.它们都不完全相同,线路错误不同。 Does anyone already faced a similar error and management to solved it ?有没有人已经面临类似的错误和管理来解决它? Thanks for your help.谢谢你的帮助。

Nicolas尼古拉斯

Edit: I tried to install it in another way: I downloaded the wheel file and installed it.编辑:我尝试以另一种方式安装它:我下载了wheel文件并安装了它。 PyCharm is now showing me a different error message : PyCharm 现在向我显示不同的错误消息:


Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "Y:\7-Python\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\MMK\Miniconda3\envs\env1\lib\site-packages\matplotlib\__init__.py", line 905, in <module>
    cbook._get_data_path("matplotlibrc"),
  File "C:\Users\MMK\Miniconda3\envs\env1\lib\site-packages\matplotlib\cbook\__init__.py", line 480, in _get_data_path
    return Path(matplotlib.get_data_path(), *args)
AttributeError: module 'matplotlib' has no attribute 'get_data_path'


I still don't have any idea what this means...我仍然不知道这意味着什么......

In PyCharm, go to File --> Settings --> Project --> Project Interpreter You will see a list of packages, click on the "+" sign at your right and search for matplotlib.在 PyCharm 中,转到 File --> Settings --> Project --> Project Interpreter 您将看到一个包列表,单击右侧的“+”号并搜索 matplotlib。 Once you find the package just click on "Install Package" Screenshot for your reference找到软件包后,只需单击“安装软件包”屏幕截图供您参考

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

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