Python pycharm and code completion

(yann) #1

I’m using pycharm as a python ide. It appears that except in the console, pycharm don’t propose any completion after typing itk module name. Code is running fine.

In the python console, completion is working as expected.

Has someone any advice on how to get the completion working ?

Thanks for any help!
Y.

1 Like
(Matt McCormick) #2

Hi Yann,

In startup code called by PyCharm, it may be helpful to add:

import itkConfig
itkConfig.LazyLoading = False
import itk

This will load all of the toolkit so it will be available for completion.

1 Like
#3

Hi!

I am running into the same issue, but @matt.mccormick’s solution does not seem to help in my case. Is it enough to add these three lines at the top of my script, or am I misunderstanding something?

The warning from PyCharm reads:

Cannot find reference ‘Image’ in ‘__init__.py’

(in the case of an itk.Image)

Some reading on the Internet seemed to imply that this is linked to the variable __all__ in __init__.py being incorrectly set by ITK’s wrappers, but my knowledge of Python is too limited to fully grasp the actual problem.

Could anyone provide additional details? It’s unnerving to see PyCharm complain so much. :laughing:

1 Like
(Matt McCormick) #4

@acoussat how is ITK’s lazy loading configuration set?

#5

Thank you for your answer. :slight_smile:
I tried with both ITK lazy loading configurations, i.e. setting LazyLoading to both True and False as specified in this message but that did not seem to help, I did not see any difference.