124

There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the "Project Interpreter" page. Even after installing the Python plugin, I don't see that setting anywhere.

Am I missing something obvious?

kousen
  • 2,897
  • 3
  • 28
  • 26

5 Answers5

165

With the Python plugin installed:

  1. Navigate to File > Project Structure.
  2. Under the Project menu for Project SDK, select "New" and
  3. Select "Python SDK", then select "Local".

Provided you have a Python SDK installed, the flow should be natural from there - navigate to the location your Python installation lives.

Naman
  • 27,789
  • 26
  • 218
  • 353
Makoto
  • 104,088
  • 27
  • 192
  • 230
  • 2
    Is there a way to have two intepreters, one for python and one for java *at the same time*? Meaning I dont have to switch back and forth. – David Williams Apr 19 '15 at 03:13
  • 19
    @DavidWilliams Yes, you should create Java project with Python *facet* for the same module. You can do that either in new project wizard (select Python under "Additional Libraries and Frameworks" on the first page) or in project structure later (*File | Project Structure | Facets*). – east825 May 31 '15 at 16:02
  • Even though I have one this before it requires research to figure out how to repeat the process.Also the process has been changing with most new IJ releases. – WestCoastProjects Jul 30 '15 at 20:23
  • 1
    For the latest versions of Jetbrains IDEs "Project structure" is inside the settings menu `ctrl + alt + S` – Matteo Oct 30 '19 at 00:13
18

I was getting the error (IntelliJ on Ubuntu 18.04) while python SDK was configured.

To fix that, I had to do this:

  1. File -> Project Structure -> Modules
  2. Click on the Dependencies tab, and click on + and select the python SDK

    enter image description here

  3. Click on Apply

After that, the warning went away and autocompletion also started working properly

Junaid
  • 3,477
  • 1
  • 24
  • 24
11

So here is a simple project, where I have used Selenium and added that using external path

Error

Now you need to open Project Structure and go to SDK Section

Project Structure

Now Select your project's virtual environment. In the Classpath tab add the PYTHONPATH by clicking + button

Add SDK

and now the modules will be recognized

Module recognized

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • Thanks Tarun. It seems I was not using the newly installed Python SDK with PySpark in IntelliJ IDE. And thanks for pointing out the site-packages (and PythonPath classpath) – John Jai Apr 02 '18 at 16:11
3

Follow these steps:

  1. Open Setting (Ctrl + Alt + s)
  2. Click on plugins
  3. Find Browse Repositories and click
  4. Search for "python"
  5. Select Python SDK or pycharm
  6. Restart the IDE
  7. Go to project structure
  8. Select the python SDK in projects or create a new project with python SDK.
Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
Prakash
  • 368
  • 5
  • 16
3

If you have multiple modules in your project, with different languages, you can set the interpreter in the following way:

  • File -> Project Structure...
  • Select Modules in the list on the left
  • Select the Python module in the list of modules
  • On the right-hand side, either choose an existing Python SDK from the dropdown list, or click on the New... button to create either a virtualenv, or create a new Python SDK from a Python installation on your system.
Zoltán
  • 21,321
  • 14
  • 93
  • 134