Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm "no module named sys"

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.

like image 872
Mawg says reinstate Monica Avatar asked Mar 16 '16 15:03

Mawg says reinstate Monica


People also ask

How to install sys module in PyCharm?

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.

How do I get sys in PyCharm?

File -> Settings -> Project: (your_project_name) -> Project Interpreter -> press the + symbol -> search for 'system' and install package. This solved the problem for me.

Do you have to import sys in Python?

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.


2 Answers

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.

like image 192
Brynn McCullagh Avatar answered Sep 23 '22 21:09

Brynn McCullagh


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.

like image 28
linusg Avatar answered Sep 22 '22 21:09

linusg