Setting up python interpreter in intellij on multilingual (scala / java / python) module

As shown in the following screenshot, python 2.7.2 sdk is configured

enter image description here

Also:

  • the python facet has been added to the "spark-parent" module
  • directory "python" was added as source root

But as you can see, all the standard python imports don't work. Note that custom intrinsically safe python classes ("pyspark") are allowed.enter image description here

In response to answer from Dwight Brown: Changing project SDK from java to python doesn't work in this mixed project: see screenshot below

enter image description here

+3


source to share


3 answers


I have the same problem.

After some trying I found this solution

  • create only empty module named java-dep-python

    etc. then add it to project

    <module relativePaths="false" type="JAVA_MODULE" version="4">
      <component name="NewModuleRootManager" inherit-compiler-output="true">
        <orderEntry type="jdk" jdkName="Python 2.7" jdkType="Python SDK" />
        <orderEntry type="sourceFolder" forTests="false" />
      </component>
    </module>
    
          

  • change all your mixed modules to add a new empty module as a dependency

    <module relativePaths="true" type="JAVA_MODULE" version="4">
      <component name="FacetManager">
        <facet type="Python" name="Python">
          <configuration sdkName="Python 2.7" />
        </facet>
      </component>
      <component name="NewModuleRootManager" inherit-compiler-output="true">
        ... ...
        <orderEntry type="inheritedJdk" />
        <orderEntry type="module" module-name="java-dep-python" scope="PROVIDED" />
        ... ...
      </component>
    </module>
    
          



Please note that the keyword PROVIDED

helps so that this module is not required by any artifacts

This works for me, now that standard python imports are good.

IDEA 14.0.3 build # IU-139.1117

+3


source


you must also install the SDK of the "Team" project; and install the project SDK in the python SDK you are going to use.



This might help too. multiple languages ​​in one project in Intellij idea

+2


source


almost there, the only thing you were missing was installing the Python interpreter for the actual aspect. I had to restart Intellij to actually apply things.

enter image description here

+1


source







All Articles