I am having trouble getting my Python environment set up and I know that I have screwed something up. I am building from sources and install to the system site-packages directory. The install stores many ITK related .py files and an itk directory. I receive the following error when running Python from any directory other than the build directory. Interestingly enough “import itk” works from any directory, but none of the attributes are correctly seen. The inspect module shows that itk.pyc contains the import code. I know that I should not run Python from the build directory, but can you tell me the best practices for setting PYTHONPATH, if it needs to be set at all? I did set it to the itk subdirectory of site-packages, but this did not work. It seems that the problem should be very easy to solve and maybe it just involves my removing some cruft from the lib64 directories.
import itk
itk.Image
Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘module’ object has no attribute ‘Image’
These are set to system locations, but the WrapITK.pth file still refers to the build directory. There are numerous ITK related .py files and an itk directory that was installed in the system directory.
How is WrapITK.pth created and why would it be pulling paths from the local build directory instead of directories created with those variables?
Matt, thank you very much for your help and vigilance. The error was ultimately that I had an itk.py (also itk.pyc) file in the directory that I was working from. This screwed things up pretty good.