ChristophKirst / ClearMap

ClearMap is a python toolbox for the analysis and registration of volumetric data from cleared tissues.
http://christophkirst.github.io/ClearMap/build/html/index.html
GNU General Public License v3.0
49 stars 40 forks source link

error importing VoxelizationCode.pyx #1

Closed mgxd closed 8 years ago

mgxd commented 8 years ago

Hello, I'm stuck at an error that says there is no module named VoxelizationCode.

The full output:

Elastix sucessfully initialized from path: /om/user/mathiasg/elastix
Traceback (most recent call last):
  File "parameter_file_template.py", line 15, in <module>
    from ClearMap.ImageProcessing.CellDetection import detectCells
  File "/om/user/mathiasg/envs/idisco_env/lib/python2.7/site-packages/ClearMap-0.9.2-py2.7.egg/ClearMap/ImageProcessing/CellDetection.py", line 38, in <module>
    import ClearMap.ImageProcessing.SpotDetection
  File "/om/user/mathiasg/envs/idisco_env/lib/python2.7/site-packages/ClearMap-0.9.2-py2.7.egg/ClearMap/ImageProcessing/SpotDetection.py", line 52, in <module>
    from ClearMap.ImageProcessing.IlluminationCorrection import correctIllumination
  File "/om/user/mathiasg/envs/idisco_env/lib/python2.7/site-packages/ClearMap-0.9.2-py2.7.egg/ClearMap/ImageProcessing/IlluminationCorrection.py", line 40, in <module>
    from ClearMap.Visualization.Plot import plotTiling
  File "/om/user/mathiasg/envs/idisco_env/lib/python2.7/site-packages/ClearMap-0.9.2-py2.7.egg/ClearMap/Visualization/Plot.py", line 24, in <module>
    import ClearMap.Analysis.Voxelization as vox
  File "/om/user/mathiasg/envs/idisco_env/lib/python2.7/site-packages/ClearMap-0.9.2-py2.7.egg/ClearMap/Analysis/Voxelization.py", line 16, in <module>
    import ClearMap.Analysis.VoxelizationCode as vox
ImportError: No module named VoxelizationCode

I thought it was an error with pyximport - but even after simplifying Voxelization.py:

import numpy
import math

import ClearMap.IO as io
import pyximport; pyximport.install()
#pyximport.install(setup_args={"include_dirs":numpy.get_include()}, reload_support=True)

#import ClearMap.IO as io
import ClearMap.Analysis.VoxelizationCode as vox

the .pyx module was not found. I'm running this on a freshly made environment, including up to date Cython and Python 2.7. Any ideas why this could be?

mgxd commented 8 years ago

I've worked around the problem by generating the c code with cython VoxelizationCode.pyx then compiling the c code into .so gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I path/to/python -o VoxelizationCode.so VoxelizationCode.c

finally, I made another file VoxelizationCode.py

def __bootstrap__():
   global __bootstrap__, __loader__, __file__
   import sys, pkg_resources, imp
   __file__ = pkg_resources.resource_filename(__name__,'VoxelizationCode.so')
   __loader__ = None; del __bootstrap__, __loader__
   imp.load_dynamic(__name__,__file__)
__bootstrap__()

This allowed me to import the package