4

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

enter image description here

Also:

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

But as you can see all of the standard python imports are failing. Note that the custom spark python ('pyspark') classses ARE resolved.enter image description here

In response to the answer from Dwight Brown: changing the Project SDK away from java to python does not work in this mixed project: see screenshot below

enter image description here

5
  • @Victor I deleted the pycharm tag since I am using the python plugin in intellij and not pycharm. I guess they are more different than anticipated. Commented Dec 10, 2014 at 21:50
  • Sorry, I deleted the comment for nothing :/ Idea? I don't know then, never tried to use python under idea.. Commented Dec 10, 2014 at 21:51
  • @VictorPolevoy It generally works very well. Just wonderful. This particular project is a bit complicated to configure. Commented Dec 10, 2014 at 21:53
  • We are going offtopic here, but you interested me in making some research.. Commented Dec 10, 2014 at 21:54
  • SGTM sounds good to me. Commented Dec 10, 2014 at 21:59

4 Answers 4

4

almost there, the only thing you were missing is to set the Python interpreter for the actual facet. I had to restart Intellij in order for things to actually apply.

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

you had to restart intellij? that might be what I were missing. That's pretty extreme.
3

I have the same problem.

After some tries I found this solution

  1. create a just 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>
    
  2. change all your mixed modules to add this new empty module as 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>
    

Note that the PROVIDED keyword do help that this module is not required by any artifacts

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

IDEA 14.0.3 build #IU-139.1117

Comments

2

the Project SDK needs to be set as well 'Command ;' and set the Project SDK to python SDK you intend to use.

This might be of some help as well. multiple languages in the same project in Intellij idea

4 Comments

For Project | Project SDK it is set to Java 1.7 That is not where python SDK is supposed to be set. Do you have more details or another suggestion?
Well I am trying this to set Project | Project SDK to Python 2.7.2 This has obvious disadvantage: breaks all the scala/java code. Do you have any comments or improvements on this?
Did you try the link for multiple languages?
For this project we need both python and scala/java in the SAME modules. That link talks about single-language modules.
1

I had the same question with a clj/py project. I followed the instructions and got the issue that I couldn't then run clj. This is the final status of my project setup.

  • Add a new python module to the project with the interpreter of your choice module settings for python module

module settings for python module

  • Go back to Project settings and make sure that the default sdk up set up main project settings

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.