How to Add Java Libraries to Jython Project in PyCharm Community Edition?

97 views Asked by At

I'm currently working on a Jython project (using Jython 2.7.3) in PyCharm Community Edition (2023.2.3) and I'm having difficulty configuring Java libraries in the IDE. Although my code runs fine when executed (the Java imports are working as expected at runtime), PyCharm is underlining the Java import statements indicating that it cannot resolve them.

Here is what I see instead:

screenshot of linter errors on imports in editor window

Could someone guide me on how PyCharm Community Edition could recognizes the import statements?

1

There are 1 answers

0
bad_coder On

Currently there's a PyCharm bug where the linter will signal Jython imports with:

unresolved reference

See issues PY-52153 and also PY-52999. The issues have been triaged and confirmed by the JetBrains support team, so they're pending a fix but it's confirmed the bug happens with correctly configured projects through no fault of the user.

The only known workaround is using the earlier PyCharm 2021.1 as indicated in this comment and also this post as that was the last version unaffected by the bug.