python - import matplotlib & Visual Studio Code
问题描述
I'm using Visual Studio Code and want to be able to use numpy and matplotlib. The code I have is simply:
import numpy
import matplotlib.pyplot as plt
The first line works fine, but the second line returns this error:
Traceback (most recent call last):
File "c:\Users\(username)\OneDrive\College\Code\Python\test.py", line 2, in <module>
import matplotlib.pyplot as plt
File "C:\Users\(username)\anaconda3\lib\site-packages\matplotlib\__init__.py", line 205, in <module>
_check_versions()
File "C:\Users\(username)\anaconda3\lib\site-packages\matplotlib\__init__.py", line 190, in _check_versions
from . import ft2font
ImportError: DLL load failed: The specified module could not be found.
However, I do know that I have matplotlib installed on Anaconda, as trying to install it using pip tells me that Requirement already satisfied.
I'm using Visual Studio Code with Python 3.7.6 on 64-bit Windows with Anaconda.
Any help would be greatly appreciated. Thank you!
解决方案
修复,重新安装Anaconda,然后新建一个环境,然后用pip强制安装:
pip install --upgrade --force-install matplotlib
numpy 和 matplotlib 现在工作得很好:)
推荐阅读
- php - 使用正则表达式验证用户输入以防止 sql 注入
- c - 将字符添加到用 c 中的字符串初始化的字符指针
- javascript - 从 Firebase 中检索数据并显示在单独的 div 中
- kubernetes - 监控 Kubernetes pod 健康事件
- c# - MemoryMappedFile 低完整性.Net 5
- php - 在php中单击链接时永久添加文本
- python - Python包:启动脚本时未加载样式表
- javascript - 如何使自定义网站无限滚动更改 URL?
- powershell - Powershell脚本未结束任务计划程序中的任务
- android - 移除 MaterialButton 的背景颜色并设置图标