Python: Importing an .so file

Hey all -

I'm at the tail end of my IntelliJ trial. It works pretty well for both Python and Javascript, but I'm running into an issue with a legacy project.

A barebones replication of my issue can would be with the following project structure:
/myProject/ is compiled c with Python.h (see

import myExtension
print dir(myExtension)

I am able to run via the command-line and IntelliJ (Shift+F10). My issue is that the line 'import myExtension' is marked with the error 'no module named myExtension'. I've tried invalidating caches and restarting (out of desperation). Is there any way I can get Intellij to recognize this c extension module?


Comment actions Permalink

Attaching project source code.

Comment actions Permalink

I've made some progress on this. If I append my project directory to PYTHONPATH before loading IntelliJ, the error goes away AND I get auto-complete. I'm pretty happy about that, though I suspect that this is something I should be able to configure from within IntelliJ.

I'm still curious to know if A) this is a bug and IntelliJ should recognize the .so file, or B) there is a better solution.


Comment actions Permalink

Right now IntelliJ IDEA scans for native extensions only in the path of the Python interpreter. Having native extensions directly under the project is not a common scenario, and we don't currently support it directly.

Comment actions Permalink

Thanks for the reply Dmitry. That's too bad. Do you know if there is an open ticket for this bug/feature-request? Should there be one?


Comment actions Permalink

Dmitry, this doesn't seem to be so, at least under Ubuntu and Mac.

E.g. shared object /usr/lib/python2.7/lib-dynload/ is not detected by IDEA, despite its parent dir being present in Project Structure => SDKs => Classpath.

See the screenshots (not mine, but I see an absolutely identical picture in Ubuntu):

You could clearly see the /opt/.../lib-dynload directory listed under Python's "classpath" -- but the 'datetime' module  is still not resolved in the "from datetime import date" statement ("No module named datetime" error).

Is this Proj.Struct./SDK/"classpath" exactly what you mean by "the path of the Python interpreter"?
Or the paths must be specified somewhere else?

Under Windows, the same sample module 'datetime' works fine. It seems to be located in /media/OS/apz/Python27/include/datetime.h and further extracted by IDEA into IDEA's system dir:

(At least that's where 'Goto declaration' takes me to in IDEA.)

So in Windows it's not quite a shared object or dll.

Any ideas?
Should we report this as a bug in YouTrack?

Comment actions Permalink

This looks like
This problem is fixed in the Python plugin for IntelliJ IDEA 12.1.5 EAP.

Comment actions Permalink

Oops. Sorry, my bad. I must've checked Youtrack myself...
Thanks for the hint!


Please sign in to leave a comment.