使用 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 的模块"
发布评论