Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: numpy.core.multiarray failed to import #12

Closed
GiuliaZorzi opened this issue Dec 30, 2021 · 3 comments
Closed

ImportError: numpy.core.multiarray failed to import #12

GiuliaZorzi opened this issue Dec 30, 2021 · 3 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@GiuliaZorzi
Copy link

Hello,

I want to use livermask to segment CT images as a part of a project through my organization. We are really excited to use your tool because it will automate a lot of the segmentation we would have otherwise had to do. However, I stumbled on the following error:
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "/Users/giulia/.conda/envs/liver/bin/livermask", line 33, in
sys.exit(load_entry_point('livermask==1.3.0', 'console_scripts', 'livermask')())
File "/Users/giulia/.conda/envs/liver/bin/livermask", line 25, in importlib_load_entry_point
return next(matches).load()
File "/Users/giulia/.conda/envs/liver/lib/python3.8/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/Users/giulia/.conda/envs/liver/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/Users/giulia/.conda/envs/liver/lib/python3.8/site-packages/livermask-1.3.0-py3.8.egg/livermask/livermask.py", line 6, in
from scipy.ndimage import zoom
File "/Users/giulia/.conda/envs/liver/lib/python3.8/site-packages/scipy-1.5.4-py3.8-macosx-11.0-arm64.egg/scipy/ndimage/init.py", line 151, in
from .filters import *
File "/Users/giulia/.conda/envs/liver/lib/python3.8/site-packages/scipy-1.5.4-py3.8-macosx-11.0-arm64.egg/scipy/ndimage/filters.py", line 37, in
from . import _nd_image
ImportError: numpy.core.multiarray failed to import

I have installed numpy==1.19.5 as requested by livermask and I work on a Macos M1 machine.
Could you please help me?

@andreped
Copy link
Owner

Sad to see that you are having issues.

I am currently on holiday until January 5th, and I cannot do any debugging myself on a machine with macOSX until then.

However, from your prompt it looks like you have used a conda virtual environment when installing livermask. I don't really use conda myself, as I historically have had all kinds of issues with it. Personally, I prefer pip. There were some people that had issues installing pandas on an M1 before (see here). This was solved using pip instead. Therefore, it is natural to think that this might be fixed by simply using pip instead of conda, but lets try something first.

From this thread it seems like a lot of people have had the same issue, and it was resolved by downgrading numpy. However, I am not sure that will fix your issues. But you could try. Simply run the command (after install of livermask):

pip install numpy==1.19.3

If this isn't working, could you try making a virtual environment with virtualenv and installing, like so:

pip install virtualenv
virtualenv -ppython3 venv --clear
source ./venv/bin/activate
pip install git+https://github.com/andreped/livermask.git

The package was setup to work with pip, and any incompatibilities with conda, is somewhat outside of what I can do currently. At least on macOSX.

Also, which Python and pip versions are you using? Would be nice to know if you are using regular Python 3.x or the one from conda. If you have two, as you have conda installed, check which versions are in use by:

python -V
python3 -V
which python
which python3

If you have some specific python-version installed, such as python3.6, you could also run the command:

python3.6 -V
which python3.6

@andreped andreped self-assigned this Dec 30, 2021
@andreped andreped added bug Something isn't working good first issue Good for newcomers labels Dec 30, 2021
@andreped
Copy link
Owner

andreped commented Dec 31, 2021

@GiuliaZorzi One of my co-workers, @jpdefrutosSINTEF, was able to perform some tests on macOSX for me. He does not have access to an M1 macbook, but I believe livermask should be forward compatible on said operating system.

We found some bugs, which have now been fixed. A new patch release has been made. For info on edits, see here.

However, the bugs we found are not related to the issue you have. I believe you have this problem as you installed livermask using conda instead of pip.

Therefore, to install and use livermask, this should work (will install the most recent version with the new bug fixes):

1) Install:
virtualenv -ppython3 venv --clear
source venv/bin/activate
pip install git+https://github.com/andreped/livermask.git

2) Usage:
livermask --input /path/to/some/volume.nii --output /path/to/some/output

If you observe any problems, I recommend adding the --verbose flag, as you will get more information on the progress. Especially if it fails. If you wish to perform vessel segmentation, please, add the --vessels flag. More information regarding usage can be found here.

To avoid these things from happening in the future, I have added inference test workflows for all three operating systems. They seem to build, install, and run livermask well on the cloud (on a fresh install). See here for information regarding the build.

Therefore, using pip for installing should solve your issue. To avoid any confusion in the future, I now added information regarding this both here and here. Hopefully, the CLI works better for you now and for others in the future.

I am closing for now, but if you experience any new issues, please, let me know :]

@andreped
Copy link
Owner

andreped commented Jan 31, 2022

@GiuliaZorzi did you manage to get it working? livermask is now published on PyPI, and you can therefore install it simply by:

pip install livermask

Would be nice to know whether this is an M1-related issue or not. Unit tests are also performed on the cloud for building, installing, and testing the software, and everything seems to work using pip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants