Downgrading numpy to 1.19.3 prevents itom from starting python: "Numpy.core.multiarray failed to import"

Issue #166 closed
Georg Laage created an issue

Hello,

The usage of certain AI related packages like tensorflow/Keras requires to specificall install numpy version 1.19.3. Installing this however completely breaks ITOM.
Reproduce by:
1. ITOM → Package manager
2. Choose package numpy and “Update”
3. Enter requirements numpy==1.19.3
4. Update
5. Restart Itom
At startup Itom should now show the message:

>>Error when starting the application:
Numpy.core.multiarray failed to import. Please verify that you have numpy 1.6 or higher installed.

Apparently this is a somewhat known bug which can occur when using cv2. There are reports which suggest this can be fixed when importing Numpy.core.multiarray before importing cv2. (Not sure though if this is applicable here since it is unknown if Itom or cv2 are the reason for this error)
This has been tested with a complete fresh install of ITOM 4.1 without adding any other packages.

Let me know if any more input/info is required.

Cheers,
Georg

Comments (2)

  1. M. Gronle

    Hi Georg,

    Numpy provides a C-API, such that it can be directly integrated into C/C++ projects. This is what itom does in order to provide the compatibility between numpy.ndarrays and itom.dataObjects in Python or to provide the itom plots for numpy.ndarrays, too. This C-API of Numpy might change from major / minor version of Numpy to another one. Therefore, Numpy is the only Python package that is mandatory to run itom, but which cannot be simply changed to another major/minor version without recompiling itom itself.

    The error message is probably somehow not clear (I will keep this issue open to improve this error message), but it means, that the available Numpy version is not compatible with the version, that was used during the compilation of itom due to an incompatible C-API of numpy.

    Currently, the official windows setup of itom 4.1 is compiled with numpy 1.20 (see https://sourceforge.net/projects/itom/files/v4.1.0/). itom 4.0 has been compiled with numpy 1.18.5 (see https://sourceforge.net/projects/itom/files/v4.0.0/). Maybe you could use an older version of itom, or you can also compile itom by yourself and use your desired version of numpy.

    If itom is already compiled, you can only change to another Python version, whose patch version number is different from the one, itom was compiled against. The same holds for Numpy. All other python packages can be changed to arbitrary versions (however, they are also sometimes dependent to specific Numpy versions - like tensorflow, Keras, scipy, scikit-image…).

    For a self-compiled version of itom, you mainly need Visual Studio 2015 or higher and git (git-scm.com). Then download a suitable “All-In-One Build Setup” from https://sourceforge.net/projects/itom/files/all-in-one-build-setup/. Unpack the zip archive (and the optional one for point cloud support). Then run the setup_itom_all-in-one.bat from the _install_ folder. For more information see https://itom.bitbucket.io/latest/docs/02_installation/install_all-in-one_development_setup.html.

    If you would like to use another Numpy than shipped with the Python in the “all-in-one build setup” package, update Numpy and further dependent packages within the Python, that is included in this directory. Then continue with the bat script, mentioned above. This batch file mainly downloads the main repositories for itom, its main plugins and designer plugins (plots), configures the project based on your system and compiles the entire project. At the end, you can start it by executing the resulting qitom.exe or itom.bat in the build directory. By this bat file, it is not necessary to add pathes of the contained 3rdParty libraries (like OpenCV, Qt…) to the PATH environment variables.

    If you are interested in compiling itom by yourself and have further questions, feel free to contact us.

    Cheers

    Marc

  2. M. Gronle

    closes issue #166: If Numpy could not be loaded (not available, or incompatible to the version used to compile itom), the detailed failure message is now displayed.

    → <<cset 3f3a3340f725>>

  3. Log in to comment