Using PyCharm community edition and Python 2.7,
import traceback import 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).
Any ideas?
[Update] to the commentators so far, thanks.
The IDE does not offer sys
for auto-complete after import sy
.
When I start the interpreter which the IDE uses form the command line, then import sys
works.
PyCharm can do both. Type the name of the package and hit Alt-Enter , then choose Install and Import package . PyCharm will do both: you'll see a notification during the installation, then the import will be generated in the right way, according to your project styles.
File -> Settings -> Project: (your_project_name) -> Project Interpreter -> press the + symbol -> search for 'system' and install package. This solved the problem for me.
Like all the other modules, the sys module has to be imported with the import statement, i.e. The sys module provides information about constants, functions and methods of the Python interpreter.
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.
Make sure you've chosen the right Interpreter path and check some other run settings. Go to Run > Edit Configurations... and check, if some configurations seem to be wrong.
EDIT: Under Linux, you have often Python 2 and 3 installed, be sure to pick the correct one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With