How do I get IntelliJ to recognize common Python modules?

前端 未结 12 1298
甜味超标
甜味超标 2020-12-04 09:09

I\'m using IntelliJ 10 IDEA Ultimate Edition.

I\'ve created a new file Test.py, and IntelliJ has correctly switched to Python parsing mode. (I can confirm this by t

相关标签:
12条回答
  • 2020-12-04 09:47

    Have you set up a python interpreter facet?

    Open Project Structure CTRL+ALT+SHIFT+S

    Project settings -> Facets -> expand Python click on child -> Python Interpreter

    Then:

    Project settings -> Modules -> Expand module -> Python -> Dependencies -> select Python module SDK

    0 讨论(0)
  • 2020-12-04 09:47

    This is how i solved my problem (i have imported the project and it was showing there only, newly created files were not showing those errors):

    1) Command + alt + R (Control in case of windows

    2) Debug window will appear, select your file and press right arrow (->) and choose Edit then press enter (Edit configuration setting window will appear)

    3) Under configuration, at the bottom you can see the error (please select a module with a valid python sdk), So in Python Interpreter, check Use Specified Interpreter, then in drop down you select your Python version

    (In case python is not there download python plugin for intelliJ using following link https://www.jetbrains.com/help/idea/2016.3/installing-updating-and-uninstalling-repository-plugins.html

    4) Click on apply then close it.

    Bingo it's done.

    0 讨论(0)
  • 2020-12-04 09:48

    Few steps that helped me (some of them are mentioned above):

    Open project structure by:

    command + ; (mac users) OR right click on the project -> Open Module Settings

    1. Facets -> + -> Python -> <your-project> -> OK
    2. Modules -> Python -> <select python interpreter>
    3. Project -> Project SDK -> <select relevant SDK>
    4. SDKs -> <make sure it's the right one>

    Click OK.

    Open Run/Debug Configurations by: Run -> Edit Configurations

    1. Python Interpreter -> <make sure it's the right one>

    Click OK.

    0 讨论(0)
  • 2020-12-04 09:52

    Another possible fix (solved my problem)

    You might have configured the environment properly but for some reason it broke along the way. In this case go to:

    file > project settings > modules
    

    Deploy the list of SDKs and look for a red line with [invalid] at the end. If you find one, you have to recreate a python sdk.

    It is likely that your previously working SDK is there too, but not red. Delete it.

    Now you can click on the new button and add your favorite python virtualenv. And it should work now.

    0 讨论(0)
  • 2020-12-04 09:53

    Here's what I had to do. (And I probably forgot an important aspect of my problem, which is that this wasn't set up as a Python project originally, but a Java project, with some python files in them.)

    Project Settings -> Modules -> Plus button (add a module) -> Python

    Then, click the "..." button next to Python Interpreter.

    In the "Configure SDK" dialog that pops up, click the "+" button. Select "Python SDK", then select the default "Python" shortcut that appears in my finder dialog

    Wait about 5 minutes. Read some productivity tips. :)

    Click Ok

    Wait for the system to rebuild some indexes.

    Hooray! Code hinting is back for my modules!

    0 讨论(0)
  • 2020-12-04 09:54

    My problem was similar to @Toddarooski 's, except that the module I had, under the "Dependencies" tab, had no SDK listed. I right clicked on 'SDK', picked edit from the drop down menu, and selected my Python SDK. That did the trick.

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