1

In the Project Properties > PyDev - PYTHONPATH > Source Folders tab I have my Java source directory listed. However, when I try to run my Python file using right-click > Run As > Jython Run, I get "ImportError: cannot import name Person". This is a very simple Python script:

from com.entities import Person

person = Person()
print person.getFirstName()

I've read some people discuss creating a JAR of the Java application, and then referencing the JAR, but it seems pretty clear that I should be able to reference my source directory.

EDIT

So I just tested using a JAR reference containing my class and that worked. So why won't a source folder reference work?

1 Answer 1

1

Actually, it depends on how you structure your java code... you have to add as a source folder the folder that has your .class files (as that's the folder that's added to your pythonpath -- so, depending on how you structure your project, that may be your 'bin' folder).

Reference: read the last lines in: http://pydev.org/manual_101_project_conf2.html

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

1 Comment

Thanks Fabio, I discovered something similar, and as you said, it depends on your project setup. What I did instead was stick with my Java project and have my .py files "compile" into my bin, and that seemed to work.

Your Answer

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