PyCharm“没有名为 sys 的模块"

编程入门 行业动态 更新时间:2024-10-18 12:24:24
本文介绍了PyCharm“没有名为 sys 的模块"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用 PyCharm 社区版和 Python 2.7,

Using PyCharm community edition and Python 2.7,

import traceback import sys

第一行没问题,这意味着我已经正确地将 PyCharm 指向了解释器.但是,我在第二行得到没有名为 sys 的模块"(这很奇怪,因为 sys 是一个内置函数——如果你能找到解释器,你就找到了 sys).

No problem on the first line, which implies that I have pointed PyCharm correctly at the interpreter. However, I get "no module named sys" at the second line (which is strange, as sys is a builtin - if you can find the interpreter, you have found sys).

有什么想法吗?

[更新] 到目前为止的评论员,谢谢.

[Update] to the commentators so far, thanks.

IDE 不提供 sys 以在 import sy 后自动完​​成.

The IDE does not offer sys for auto-complete after import sy.

当我从命令行启动 IDE 使用的解释器时,import sys 起作用.

When I start the interpreter which the IDE uses form the command line, then import sys works.

推荐答案

我以前在 PyCharm 上遇到过这个问题.我发现重新加载解释器可以解决问题.

I have had this issue with PyCharm before. I find that reloading the interpreter fixes the issue.

文件 -> 设置 -> 项目 -> 项目解释器

File -> Settings -> Project -> Project Interpreter

删除解释器并重新添加.

Remove the interpreter and add it again.

更多推荐

PyCharm“没有名为 sys 的模块"

本文发布于:2023-11-23 20:05:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   PyCharm   sys   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!