Python 模块在终端上导入,但不在 IDLE 上导入

标签 python import module pynput

我使用 python 3.6.4,操作系统是 macOS High Sierra。

所以我已经安装了pynput。但是,我可以在终端上很好地导入它,但不能在 Python IDLE 上导入它。 enter image description here

我使用过sys.versionsys.path,它们是相同的。我的 Mac 上只安装了 python 3.6 enter image description here

有人知道原因以及如何解决吗?

最佳答案

当您安装了多个版本的 python 时,通常会发生这种情况。 在 IDLE 和终端中使用这行代码:

导入系统 系统版本 系统路径

您将获得当前Python的系统路径。现在只需删除其中一个即可。

关于Python 模块在终端上导入,但不在 IDLE 上导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49359352/

相关文章:

python - 像 Python 中的属性一样访问 OrderedDict 键

python - 如何解决 "ValueError: A ` Concatenate` 层需要具有匹配形状的输入(除了连接轴之外)”?

python - 如何获得数量为 1's are equal to or more than the number of 0' 的 n 个二进制值的所有组合?

java - Google Analytics 导入无法解决

linux - Sugarcrm 模块加载器扫描包错误

python - 服务不可用 : 503 failed to connect to all addresses during attempt to recognize audio

linux - 在 ELF 二进制文件中导入名称

python - 多次导入同一个模块

Python 模块 vs 子模块 vs 包 vs 子包

delphi - 从内部 .dll 获取模块句柄