mcberk / wrapitk

Automatically exported from code.google.com/p/wrapitk
0 stars 0 forks source link

Ubuntu 9.04 binaries dosen't seem to work #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. install itk as desicribed in wiki
2. launch ipython
3.
import itk
itk.ImageFileReader.IUS2IUS2.New()

What is the expected output? What do you see instead?

I see the following:

In [2]: itk.ImageFileReader.IUS2IUS2.New()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/borsh/<ipython console> in <module>()

/usr/lib/InsightToolkit/WrapITK/Python/itkLazy.py in __getattribute__(self,
attr)
     16       module = self.__lazy_attributes[attr]
     17       namespace = {}
---> 18       itkBase.LoadModule(module, namespace)
     19       # Load into 'namespace' first, then self.__dict__ (via
setattr) to

     20       # prevent the warnings about overwriting the 'NotLoaded'
values already

/usr/lib/InsightToolkit/WrapITK/Python/itkBase.py in LoadModule(name,
namespace)
     22     if namespace is not None:
     23         swig = namespace.setdefault('swig', imp.new_module('swig'))
---> 24         swig.__dict__.update(this_module.swig.__dict__)
     25 
     26         # don't worry about overwriting the symbols in namespace --
any common

AttributeError: 'module' object has no attribute 'swig'

here is my sys.path:

['',
 '/usr/local/bin',
 '/usr/local/lib/python2.6/dist-packages/ipython-0.10-py2.6.egg',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib/python2.6/lib-old',
 '/usr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6/dist-packages',
 '/usr/lib/python2.6/dist-packages/PIL',
 '/usr/lib/InsightToolkit/WrapITK/Python',
 '/usr/lib/python2.6/dist-packages/gst-0.10',
 '/var/lib/python-support/python2.6',
 '/usr/lib/python2.6/dist-packages/gtk-2.0',
 '/var/lib/python-support/python2.6/gtk-2.0',
 '/usr/local/lib/python2.6/dist-packages',
 '/usr/local/lib/python2.6/dist-packages/ipython-0.10-py2.6.egg/IPython/Extensions',
 u'/home/borsh/.ipython',
 '/usr/lib/InsightToolkit/WrapITK/Python/Configuration/..',
 '/usr/lib/InsightToolkit/WrapITK/Python/Configuration/../../lib']

What version of the product are you using? On what operating system?

Ubuntu 9.04 Python 2.6.2 

Please provide any additional information below.

When I compile from sources and add lib and Languages/Python to sys.path, i
can successfully use itk in python.

Original issue reported on code.google.com by boris.ka...@gmail.com on 6 Aug 2009 at 9:40

GoogleCodeExporter commented 9 years ago
x86-64 system 

Original comment by boris.ka...@gmail.com on 6 Aug 2009 at 9:41

GoogleCodeExporter commented 9 years ago
I've got the same problem, but with a different error : 
>>> import itk
>>> image_type = itk.Image[itk.US,3]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/InsightToolkit/WrapITK/Python/itkLazy.py", line 18, in __getattribute__
    itkBase.LoadModule(module, namespace)
  File "/usr/lib/InsightToolkit/WrapITK/Python/itkBase.py", line 77, in LoadModule
    LoadModule(dep, namespace)
  File "/usr/lib/InsightToolkit/WrapITK/Python/itkBase.py", line 77, in LoadModule
    LoadModule(dep, namespace)
  File "/usr/lib/InsightToolkit/WrapITK/Python/itkBase.py", line 85, in LoadModule
    if not swigModuleName in sys.modules: module = loader.load(swigModuleName)
  File "/usr/lib/InsightToolkit/WrapITK/Python/itkBase.py", line 196, in load
    return imp.load_module(name, fp, pathname, description)
  File "/usr/lib/InsightToolkit/WrapITK/lib/ITKPyBasePython.py", line 76, in <module>
    from pyBasePython import *
  File "/usr/lib/InsightToolkit/WrapITK/lib/pyBasePython.py", line 22, in <module>
    _pyBasePython = swig_import_helper()
  File "/usr/lib/InsightToolkit/WrapITK/lib/pyBasePython.py", line 20, in
swig_import_helper
    if fp is not None: fp.close()
UnboundLocalError: local variable 'fp' referenced before assignment

When looking at the pyBasePython.py file, it appears that the binaries have been
built with Swig 1.3.38. As Ubuntu 9.04 uses Python 2.6, we are hit by the issue
mentionned in the wiki page for release 0.3.0.

If I had access to the script that generated the packages, I'd be more than 
willing
to rebuild them using swig 1.3.36, shipped with Ubuntu 9.04.

Original comment by l...@unistra.fr on 10 Aug 2009 at 9:53

GoogleCodeExporter commented 9 years ago
I have got the exact same problem as l...@unistra.fr. Did you managed to get 
the script and made the rebuild?

Original comment by xmole...@gmail.com on 7 Dec 2010 at 5:03

GoogleCodeExporter commented 9 years ago
I used the following work-around for this issue : 

1. Build WrapITK, using its CMake script, and setting 
CMAKE_INSTALL_PREFIX=/usr. Other interesting settings for Python wrappers 
include WRAP_ITK_DOC and INSTALL_WRAP_ITK_COMPATIBILITY. The following steps 
assume you're located in the build directory.

2. Install it locally :
mkdir -p local_install/usr
sed -e "s/^FILE/#FILE/" -i install_wrapitk_compatibility.cmake
cmake -D CMAKE_INSTALL_PREFIX=local_install/usr -P cmake_install.cmake
sed -e "s/^#FILE/FILE/" -i install_wrapitk_compatibility.cmake

3. Copy the "InstallOnly" files :
mkdir -p local_install/usr/lib/python2.6/dist-packages
mkdir -p local_install/usr/share/cmake-2.6/Modules
cp Languages/Python/InstallOnly/WrapITK.pth 
local_install/usr/lib/python2.6/dist-packages
cp InstallOnly/FindWrapITK.cmake local_install/usr/share/cmake-2.6/Modules

4. Debianize the build (adapt the Architecture and Maintainer fields) :
mkdir -p local_install/DEBIAN
cat <<EOF > local_install/DEBIAN/control
Package: wrapitk
Version: 0.3.0
Section: libs
Priority: extra
Architecture: i386
Maintainer: John Doe <jdoe@example.com>
Description: Automated dynamic language binding for Insight Toolkit (ITK)
 WrapITK is an effort to automate the language binding process of one of
 the largest highly template-oriented c++ libraries, the Insight Toolkit
 image processing library.
 .
 Currently Python, Java and Tcl language bindings are implemented, but
 only Python is fully supported. For ITK .NET languages wrapper you may
 refer to ManagedITK.
EOF

5. Create the package :
fakeroot dpkg-deb -b local_install ./wrapitk-0.3.0.deb

This has been successfuly tested on several versions of Ubuntu (9.04, 9.10 and 
10.04, both x86 and amd64 architectures).

Note that in step 3, the Python and CMake paths should be adapted for the 
versions of the platform you're targetting. For Python `python -c "import sys; 
print sys.version[:3]"` automates the trick.

Original comment by l...@unistra.fr on 7 Dec 2010 at 5:32

GoogleCodeExporter commented 9 years ago
I am trying to execute the build procedure described in comment #4, but upon 
invoking

cmake -D CMAKE_INSTALL_PREFIX=local_install/usr -P cmake_install.cmake

I get

/lib/InsightToolkit/WrapITK/Configuration/Languages/GccXML/wrap_.cxx.in
CMake Error at Libraries/VXLNumerics/cmake_install.cmake:36 (FILE):
  file INSTALL cannot find
  "/home/bens/schoolwork/phd/labfus/WrapITK/wrapitk-0.3.0/Typedefs/wrap_vcl_complex.idx".
Call Stack (most recent call first):
  Libraries/cmake_install.cmake:37 (INCLUDE)
  cmake_install.cmake:56 (INCLUDE)

This is correct; Typedefs/ contains .i, .includes, and .mdx files, but no .idx 
files.

Therefore, the build process does not work for me, so I cannot use my WrapITK 
code on Ubuntu 10.04.

Original comment by Benjamin...@gmail.com on 8 Dec 2010 at 7:57

GoogleCodeExporter commented 9 years ago
I've re-built WrapITK from scratch using the build process I've described in 
comment #4, this time using cmake instead of ccmake. I used the following 
command line : 
cmake -D BUILD_TESTING=OFF -D CMAKE_BUILD_TYPE=Release -D 
CMAKE_INSTALL_PREFIX=/usr -D WRAP_ITK_DOC=ON -D WRAP_ITK_PYTHON=ON -D 
INSTALL_WRAP_ITK_COMPATIBILITY=ON -D WRAP_float=ON -D WRAP_signed_char=ON -D 
WRAP_signed_long=ON -D WRAP_signed_short=ON -D WRAP_unsigned_char=ON -D 
WRAP_unsigned_long=ON -D WRAP_unsigned_short=ON ../wrapitk-0.3.0

Is the cableswig package (containing cableidx, responsible for the building of 
.idx files) installed on your computer ?

Original comment by l...@unistra.fr on 10 Dec 2010 at 2:36