• 12

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

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.

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.

  • 44
Reply Report
      • 2
    • At the first the issue is disappeared, but when I try to enter another call to sys. PyCharm marks all line with "sys" as error.
      • 2
    • @Kixoms are you using conda by any chance? I had an issue where if I pointed to wrong python binary (not within the envs folder), it would give me the above error.

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.

  • 4
Reply Report

I had this problem as well and was completely stymied until I tried the following:

File -> 
Default Settings -> 
Project Interpreter
  dropdown (click the arrow) ->
Show All ->
  select your interpreter ->
Show Paths
  (bottom icon on right) ->
Add Path ->
  Enter path to libraries
  (in my case this was c:\Python35\Lib).
  • 4
Reply Report

I had this issue and I resolved it by updating the default project settings under File -> Default Settings -> Project Interpreter and then in the drop down list for Project Interpreter, selecting the same interpreter as the Run Configuration was using (in my case python 3.6)

  • 1
Reply Report

We actually no need of having "import sys" in pycharm. You can find this in 'os' module.

For example,

import os

Sys = os.sys

print("say , Good Bye")


print("Sorry, i am not exited")

I hope it will work.

  • -1
Reply Report
      • 2
    • This does work since os.sys is the os module's import of sys. But, it's more of a "private" implementation of os, and could change in between versions. It's still much safer to just import sys directly.

Trending Tags