PyCharm “no module named sys”

前端 未结 8 2254
后悔当初
后悔当初 2021-02-06 22:58

Using PyCharm community edition and Python 2.7,

import traceback
import sys

No problem on the first line, which implies that I have pointed PyC

相关标签:
8条回答
  • 2021-02-06 23:29

    Maybe you're updating your PYTHONPATH variable in your .bashrc file? It started working on, after comment PATH PATH in bash_profile.

    0 讨论(0)
  • 2021-02-06 23:32

    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.

    0 讨论(0)
  • 2021-02-06 23:36

    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")
    
    
    Sys.exit(0)
    
    print("Sorry, i am not exited")
    

    I hope it will work.

    0 讨论(0)
  • 2021-02-06 23:39

    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.

    0 讨论(0)
  • 2021-02-06 23:41

    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).
    
    0 讨论(0)
  • 2021-02-06 23:49

    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)

    0 讨论(0)
提交回复
热议问题