如何使用像 PyCharm 这样的 IDE 运行 python 使用安装在虚拟环境中的库进行编程

How to Run python program with libraries installed in virtual environment using IDE like PyCharm

我如何告诉 IDE PyCharm 我的库安装在虚拟环境中?

示例:我在虚拟机中安装了 openCV 库 environment.If 我尝试 运行 PyCharm 上的程序 IDE 它会显示像 [=14= 这样的导入]

您应该 select 在 Pycharm 设置中的虚拟环境:File->New Project Settings -> Preferences for New Projects -> Project Interpreter

从那里您可以 select 找到一个环境或单击项目解释器列表中的“+”以从路径添加您自己的环境。这个环境将被添加到列表中。您也可以在当前库列表的末尾使用“+”添加新库。

请花点时间浏览这里。