简体   繁体   English

如何在 PyCharm 上使用 anaconda 修复导入错误?

[英]How do I fix an importing error with anaconda on PyCharm?

I am on Windows 10, I've been using matplotlib as part of anaconda with PyCharm as my IDE for a while but today when I opened it and ran my script it gives me:我在 Windows 10 上,我一直使用 matplotlib 作为 anaconda 的一部分,将 PyCharm 作为我的 IDE,但今天当我打开它并运行我的脚本时,它给了我:

ImportError: DLL load failed: The specified module could not be found.

the full error message is:完整的错误信息是:

File "C:/Users/user/PycharmProjects/Myproject/Myprogram", line 3, in <module>
    from matplotlib import pyplot as plt
  File "C:\Users\user\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 36, in <module>
    from matplotlib.figure import Figure, figaspect
  File "C:\Users\user\Anaconda3\lib\site-packages\matplotlib\figure.py", line 35, in <module>
    from matplotlib import _image
  File "C:\Users\user\Anaconda3\lib\site-packages\matplotlib\_image.py", line 7, in <module>
    __bootstrap__()
  File "C:\Users\user\Anaconda3\lib\site-packages\matplotlib\_image.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
  File "C:\Users\user\Anaconda3\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

I added every PATH variables I could think of but it is still giving me the same error.我添加了我能想到的每个 PATH 变量,但它仍然给我同样的错误。 I uninstalled/reinstalled both anaconda and Pycharm to no avail.我卸载/重新安装 anaconda 和 Pycharm 都无济于事。

As I said this is very odd because the exact same script had been running without problems for a while.正如我所说,这很奇怪,因为完全相同的脚本已经运行了一段时间没有问题。

One of my students reported the same issue with import matplotlib into Jupyter notebook.我的一位学生报告了将 matplotlib 导入 Jupyter notebook 的相同问题。 He removed Anaconda with the software add/remove tool, removed the Anaconda folder, and then reinstalled.他用软件添加/删除工具删除了Anaconda,删除了Anaconda文件夹,然后重新安装。 That seems to have fixed things for him.这似乎已经为他解决了问题。 This has now worked in two cases.这现在在两种情况下都有效。

I found that I could create import errors by using PyCharm's module update function.我发现我可以通过使用 PyCharm 的模块更新功能来创建导入错误。 Instead, on Windows, go to the command line, and use the conda update <module name> command.相反,在 Windows 上,转到命令行,并使用conda update <module name>命令。 This will fetch the modules from the right repositories.这将从正确的存储库中获取模块。 Running conda update anaconda fixed my import problems by downgrading many packages I had updated with PyCharm's update facility.运行conda update anaconda通过降级我使用 PyCharm 的更新工具更新的许多包来修复我的导入问题。

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

相关问题 如何修复 pycharm 中的此导入错误? - How do I fix this importing error in pycharm? 如何修复 Anaconda Navigator 中的此错误? - How do I fix this error in Anaconda Navigator? 如何在 python 3.8 pycharm 中修复此错误? 这是关于导入包 - How can I fix this error in python 3.8 pycharm? It is about importing packages 刚装了Anaconda怎么启动spyder ide或者pycharm? - Just installed Anaconda how do I start spyder ide or pycharm? 如何让PyCharm使用通过Anaconda安装的熊猫? - How do I make pandas installed via Anaconda usable by PyCharm? 如何使用PyCharm和Anaconda创建虚拟环境? - How do I create a virtual environment using PyCharm and Anaconda? 为什么在 Python 中使用 OpenCV 和 Anaconda 导入 cv2 时出现 DLL 加载失败,我该如何解决? - Why do I get a DLL load failure when importing cv2 in Python with OpenCV and Anaconda, and how can I fix it? 使用Anaconda在PyCharm中导入PyTorch - Importing PyTorch in PyCharm using Anaconda 你如何修复python中预期的缩进块错误? 我正在使用 PyCharm - how do you fix expected indented block error in python? I'm using PyCharm Pycharm 中的“未安装 Jupyter 包”错误消息(使用 Windows)。 我该如何解决? - "Jupyter package is not installed" error message in Pycharm (using Windows). How do I fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM