Whenever I try to import modules in PyCharm, the line of code is highlighted grey and it gives me the error "unused import statement". This seems to happen for every module I try to import. Does anyone know what could be causing this?
相关问题
- Flush single app django 1.9
- How to stop a dbus gobject loop
- Python's difflib SequenceMatcher speed up
- Getting 'Missing required field: member' w
- What can be the maximum “POST” size I can have?
相关文章
- pycharm上传代码到github,为什么不能指定某一个项目,而是默认上传第一个项目
- Is there a size limit for HTTP response headers on
- Profiling Django with PyCharm
- Does there exist empty class in python?
- ImportError: No module named twisted.persisted.sty
- How to fix this strange error: “RuntimeError: CUDA
- Get a header with Python and convert in JSON (requ
- python unit testing methods inside of classes
Once you call those modules in your script, you should see those greyed out lines turn to their normal color.
You can turn off the code inspection that looks at import, but I don't advise doing that unless you're absolutely sure you don't need it.
I changed my "Unused Symbol" in Settings > Editor > Colors&Fonts > General to just be grey without the underline. This helps me quickly see if I have a variable or an import that I'm not using in my code.
Then I also changed the code inspection severity on unused. Settings > Editor > Inspections > Python > Unused local I set the severity to 'INFO' and 'In All Scopes'.
This allows you to still gain the benefit of knowing you have unused variables without it treating it like an error.
As you can see from my screenshot, I'm not using
tz
ortzinfo
even though I imported them. I find that pretty handy.You need to actually use the module.
For example, this will have a grey line:
The module
easygui
is imported and is used for nothing. So PyCharm tells you that the module is unused, not unsuccessfully imported. If you use the module in another piece of code, the grey line will disappear: