PyCharm“没有名为 sys 的模块" [英] PyCharm "no module named sys"

查看:123
本文介绍了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 的模块"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆