Autocomplete in PyCharm for Python compiled extensions

后端 未结 9 842
遥遥无期
遥遥无期 2020-12-09 02:46

When writing Python code using compiled extensions (the OpenCV Python bindings, for example), PyCharm doesn\'t seem to be aware of their availability. The imports are marked

相关标签:
9条回答
  • 2020-12-09 03:27

    I have noticed a difference in pycharm behavior depending on the way to import. using:

    import cv2
    

    the auto completion doesn't work,

    while with:

    from cv2 import cv2
    

    auto completion works

    0 讨论(0)
  • 2020-12-09 03:28

    I hate to give a "works for me" answer, but maybe the details on my environment will help you identify the problem on your end.

    I've never used PyCharm before, but I just did a test on Mac 10.6.6 using PyCharm 1.1.1, with Macports opencv +python26. The autocomplete worked fine for me the first time. I also closed and re-ran PyCharm and was able to autocomplete without doing anything further. I also had no issue with autocomplete for other native extensions I tried like cjson, procname.

    Pycharm 1.1.1 importing opencv with autocomplete.

    Perhaps it is a platform-specific issue (Windows?), or a bug affecting an older version of PyCharm?

    0 讨论(0)
  • 2020-12-09 03:34

    In my case on OS X 10.8 and PyCharm 3, IDE was automatically picking different installations of Python. I noticed this in Eclipse Pydev, which picked up the one right one and worked as expected. It was not easy to notice the difference between the two: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python

    0 讨论(0)
提交回复
热议问题