“尝试在Windows 10上打开任何Python库时,Visual Studio Code中的DLL加载失败”

问题描述 投票:0回答:1

[在运行基本的python程序时,例如一行代码:

import matplotlib.pyplot as plt

我得到答复

“ DLL加载失败:找不到指定的模块”

我在Windows 10上使用Visual Studio Code,并且是Python的初学者。我运行Python 3.7,并使用Anaconda安装了所有内容。

我已经添加了this answer中建议的各种系统环境变量。我已经验证可以在Anaconda Powershell提示中运行代码,因此在安装时Visual Studio Code和Anaconda之间似乎存在一些问题。

我一直在阅读this discussion,它似乎与问题有关,但看不到他们提供了解决方案,只是解决了问题。

---------- --------- EDIT

我能够在Spyder中加载库(请参阅注释),所以该问题可能与Visual Studio代码有关。

python dll visual-studio-code anaconda environment-variables
1个回答
0
投票

当您独立运行VS代码而不是在anaconda提示符下运行时,会发生此问题。更为复杂的解决方案是在系统路径中添加anaconda路径,并使VSCode了解conda虚拟环境。但更简单的解决方案是打开anaconda提示符,然后键入:

    (base) C:\Users\{your_user}>conda activate {your_env}
    ({your_env}) C:\Users\{your_user}>code

通过anaconda打开VSCode。希望它能工作。

© www.soinside.com 2019 - 2024. All rights reserved.