deephealthproject / pyecvl

Python wrapper for the ECVL.
MIT License
4 stars 2 forks source link

Undefined symbol when importing pyecvl.ecvl #30

Closed sanromra closed 4 years ago

sanromra commented 4 years ago

Hi!

After following the documentation and installing pyecvl(0.3.0) successfully, the following error appears when importing pyecvl.ecvl:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages/pyecvl-0.3.0-py3.8-linux-x86_64.egg/pyecvl/ecvl.py", line 21, in <module>
    from . import _core
ImportError: /home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages/pyecvl-0.3.0-py3.8-linux-x86_64.egg/pyecvl/_core.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN4ecvl17AugmentationParam3re_E

Seems that something is wrong with the binding. Does it have any quick solution?

simleo commented 4 years ago

That symbol comes from libecvl_eddl, an optional ECVL library that adds support for EDDL. Have you installed ECVL 0.2.1 with EDDL support (i.e., with the -DECVL_BUILD_EDDL=ON CMake setting)? If not, you should disable EDDL support in PyECVL by exporting the ECVL_EDDL environment variable to off or false before running the setup script.

On the other hand, if you are trying to install everything with EDDL support, make sure libecvl_eddl is being found and linked while compiling the bindings. If libecvl_eddl is not in a standard system path, follow the instructions at https://deephealthproject.github.io/pyecvl/installation.html#ecvl-installed-in-an-arbitrary-directory.

sanromra commented 4 years ago

Hi, Simone.

You were right. Something failed linking libecvl_eddl . Once made that and checked everything that you told me this is the output of running python3 setup.py install

running install
running bdist_egg
running egg_info
writing pyecvl.egg-info/PKG-INFO
writing dependency_links to pyecvl.egg-info/dependency_links.txt
writing requirements to pyecvl.egg-info/requires.txt
writing top-level names to pyecvl.egg-info/top_level.txt
reading manifest file 'pyecvl.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyecvl.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'pyecvl._core' extension
/usr/bin/gcc-8 -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Isrc -I/home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages/pybind11/include -I/home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages/pybind11/include -I/home/rasanro1/installs/install_eddl/include -I/home/rasanro1/installs/install_ecvl/include -I/home/rasanro1/.conda/envs/eddl/include/python3.8 -c src/_core.cpp -o build/temp.linux-x86_64-3.8/src/_core.o -std=c++17 -fvisibility=hidden -DECVL_WITH_DICOM -DECVL_EDDL
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from src/_core.cpp:5:
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h: In constructor ‘ecvl::Image::Image()’:
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:160:33: warning: ‘ecvl::Image::spacings_’ will be initialized after [-Wreorder]
     std::vector<float>          spacings_;          /**< @brief Space between pixels/voxels. */
                                 ^~~~~~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:125:33: warning:   ‘std::vector<int> ecvl::Image::strides_’ [-Wreorder]
     std::vector<int>            strides_;           /**< @brief Vector of Image strides. */
                                 ^~~~~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:260:5: warning:   when initialized here [-Wreorder]
     Image() :
     ^~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h: In constructor ‘ecvl::Image::Image(const std::vector<int>&, ecvl::DataType, std::__cxx11::string, ecvl::ColorType, const std::vector<float>&, ecvl::Device)’:
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:160:33: warning: ‘ecvl::Image::spacings_’ will be initialized after [-Wreorder]
     std::vector<float>          spacings_;          /**< @brief Space between pixels/voxels. */
                                 ^~~~~~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:125:33: warning:   ‘std::vector<int> ecvl::Image::strides_’ [-Wreorder]
     std::vector<int>            strides_;           /**< @brief Vector of Image strides. */
                                 ^~~~~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:281:5: warning:   when initialized here [-Wreorder]
     Image(const std::vector<int>& dims, DataType elemtype, std::string channels, ColorType colortype,
     ^~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h: In copy constructor ‘ecvl::Image::Image(const ecvl::Image&)’:
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:160:33: warning: ‘ecvl::Image::spacings_’ will be initialized after [-Wreorder]
     std::vector<float>          spacings_;          /**< @brief Space between pixels/voxels. */
                                 ^~~~~~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:125:33: warning:   ‘std::vector<int> ecvl::Image::strides_’ [-Wreorder]
     std::vector<int>            strides_;           /**< @brief Vector of Image strides. */
                                 ^~~~~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/core/image.h:309:5: warning:   when initialized here [-Wreorder]
     Image(const Image& img) :
     ^~~~~
In file included from src/func_binder.hpp:28,
                 from src/_core.cpp:7:
/home/rasanro1/installs/install_ecvl/include/ecvl/support_eddl.h: In constructor ‘ecvl::DLDataset::DLDataset(const std::filesystem::__cxx11::path&, int, ecvl::DatasetAugmentations, ecvl::ColorType, ecvl::ColorType, bool)’:
/home/rasanro1/installs/install_ecvl/include/ecvl/support_eddl.h:70:26: warning: ‘ecvl::DLDataset::augs_’ will be initialized after [-Wreorder]
     DatasetAugmentations augs_; /**< @brief ecvl::DatasetAugmentations to be applied to the Dataset images (and ground truth if exist) for each split. */
                          ^~~~~
/home/rasanro1/installs/install_ecvl/include/ecvl/support_eddl.h:68:15: warning:   ‘ecvl::ColorType ecvl::DLDataset::ctype_’ [-Wreorder]
     ColorType ctype_; /**< @brief ecvl::ColorType of the Dataset images. */
               ^~~~~~
In file included from src/func_binder.hpp:28,
                 from src/_core.cpp:7:
/home/rasanro1/installs/install_ecvl/include/ecvl/support_eddl.h:81:5: warning:   when initialized here [-Wreorder]
     DLDataset(const std::filesystem::path& filename,
     ^~~~~~~~~
/usr/bin/g++-8 -pthread -shared -B /home/rasanro1/.conda/envs/eddl/compiler_compat -L/home/rasanro1/.conda/envs/eddl/lib -Wl,-rpath=/home/rasanro1/.conda/envs/eddl/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.8/src/_core.o -L/home/rasanro1/installs/install_opencv/lib -L/home/rasanro1/installs/install_eddl/lib -L/home/rasanro1/installs/install_ecvl/lib -Wl,-R/home/rasanro1/installs/install_eddl/lib -Wl,-R/home/rasanro1/installs/install_ecvl/lib -ldataset -lecvl_core -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_photo -lstdc++fs -lyaml-cpp -ldcmdata -ldcmimage -ldcmimgle -ldcmjpeg -li2d -lijg8 -lijg12 -lijg16 -loflog -lofstd -lecvl_eddl -leddl -o build/lib.linux-x86_64-3.8/pyecvl/_core.cpython-38-x86_64-linux-gnu.so
/home/rasanro1/.conda/envs/eddl/compiler_compat/ld: /home/rasanro1/installs/install_opencv/lib/libopencv_imgproc.so: .dynsym local symbol at index 2 (>= sh_info of 2)
/home/rasanro1/.conda/envs/eddl/compiler_compat/ld: /home/rasanro1/installs/install_opencv/lib/libopencv_imgproc.so: .dynsym local symbol at index 3 (>= sh_info of 2)
/home/rasanro1/.conda/envs/eddl/compiler_compat/ld: /home/rasanro1/installs/install_opencv/lib/libopencv_imgproc.so: .dynsym local symbol at index 4 (>= sh_info of 2)
/home/rasanro1/.conda/envs/eddl/compiler_compat/ld: /home/rasanro1/installs/install_opencv/lib/libopencv_photo.so: .dynsym local symbol at index 2 (>= sh_info of 2)
/home/rasanro1/.conda/envs/eddl/compiler_compat/ld: /home/rasanro1/installs/install_opencv/lib/libopencv_photo.so: .dynsym local symbol at index 3 (>= sh_info of 2)
/home/rasanro1/.conda/envs/eddl/compiler_compat/ld: /home/rasanro1/installs/install_opencv/lib/libopencv_photo.so: .dynsym local symbol at index 4 (>= sh_info of 2)
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/pyecvl
copying build/lib.linux-x86_64-3.8/pyecvl/version.py -> build/bdist.linux-x86_64/egg/pyecvl
copying build/lib.linux-x86_64-3.8/pyecvl/_core.cpython-38-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg/pyecvl
copying build/lib.linux-x86_64-3.8/pyecvl/__init__.py -> build/bdist.linux-x86_64/egg/pyecvl
copying build/lib.linux-x86_64-3.8/pyecvl/ecvl.py -> build/bdist.linux-x86_64/egg/pyecvl
byte-compiling build/bdist.linux-x86_64/egg/pyecvl/version.py to version.cpython-38.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyecvl/__init__.py to __init__.cpython-38.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyecvl/ecvl.py to ecvl.cpython-38.pyc
creating stub loader for pyecvl/_core.cpython-38-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/pyecvl/_core.py to _core.cpython-38.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pyecvl.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyecvl.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyecvl.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyecvl.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyecvl.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyecvl.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/pyecvl-0.3.0-py3.8-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pyecvl-0.3.0-py3.8-linux-x86_64.egg
creating /home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages/pyecvl-0.3.0-py3.8-linux-x86_64.egg
Extracting pyecvl-0.3.0-py3.8-linux-x86_64.egg to /home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages
Adding pyecvl 0.3.0 to easy-install.pth file

Installed /home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages/pyecvl-0.3.0-py3.8-linux-x86_64.egg
Processing dependencies for pyecvl==0.3.0
Searching for numpy==1.18.4
Best match: numpy 1.18.4
Adding numpy 1.18.4 to easy-install.pth file
Installing f2py script to /home/rasanro1/.conda/envs/eddl/bin
Installing f2py3 script to /home/rasanro1/.conda/envs/eddl/bin
Installing f2py3.8 script to /home/rasanro1/.conda/envs/eddl/bin

Using /home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages
Searching for pybind11==2.5.0
Best match: pybind11 2.5.0
Adding pybind11 2.5.0 to easy-install.pth file

Using /home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages
Searching for setuptools==46.4.0.post20200518
Best match: setuptools 46.4.0.post20200518
Adding setuptools 46.4.0.post20200518 to easy-install.pth file
Installing easy_install script to /home/rasanro1/.conda/envs/eddl/bin

Using /home/rasanro1/.conda/envs/eddl/lib/python3.8/site-packages
Finished processing dependencies for pyecvl==0.3.0

When trying to import now import pyeddl.eddl the following error appears:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rasanro1/temp/pyecvl/pyecvl/ecvl.py", line 21, in <module>
    from . import _core
ImportError: cannot import name '_core' from 'pyecvl' (/home/rasanro1/temp/pyecvl/pyecvl/__init__.py)

Any idea on this error?

simleo commented 4 years ago

Are you in the pyecvl source directory? Move to some other directory and try the import again. If you are in the source directory, the local pyecvl dir takes precedence, and naturally there is no extension file there.

sanromra commented 4 years ago

That was it!

Thanks a lot. I'm closing the issue.