【问题标题】:Intellij Idea: Python import showing error even when code using module is runningIntellij Idea:即使使用模块的代码正在运行,Python 导入也会显示错误
【发布时间】:2017-07-07 06:16:50
【问题描述】:

我正在使用编辑器 Intellij Idea,Ultimate 2017 Edition 开发一个 python 项目。

在我的工作文件sample.py 代码看起来像

import os

def sample_fuc():
    print(os.stat("C:\\Users\admin"))

Python SDK 已配置,代码运行良好 [通过 intellij 运行配置运行时] 并打印所需结果,但不知何故 Intellij 无法找到模块 os 并显示错误 No module named os

所以,我想在这里了解两件事:

1.) Intellij IDEA 如何搜索 Python 库中可用的模块。我是否需要在 intellij 中进行配置以查找可用模块。是否有默认设置,如果有,为什么像 os 这样的通用模块在默认路径中不可用?

2.) 如果我需要配置,python 通常在 Windows 上存储已安装模块的所有目录路径是什么?

【问题讨论】:

    标签: python intellij-idea python-3.6


    【解决方案1】:

    可能 intellij 无法识别您的 python 解释器路径。

    参考:How do I get IntelliJ to recognize common Python modules?

    【讨论】:

    • 我相信python解释器已经配置好了,这就是我能够通过运行配置运行代码的方式。
    猜你喜欢
    • 2021-05-05
    • 2013-11-09
    • 1970-01-01
    • 2021-09-21
    • 2014-09-14
    • 2011-09-27
    • 2016-11-21
    • 1970-01-01
    • 2015-09-04
    相关资源
    最近更新 更多