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

[BUG] Installation via metapackage doesn't come with appropriate libpng on Silicon Mac #205

Open
alessandrofelder opened this issue Jun 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@alessandrofelder
Copy link
Member

Describe the bug
brainreg should be useable on all platforms when installed via the metapackage on PyPI. Local installation on M2 Mac seems successful, but running the CLI on sample data fails by not finding the libpng dynamic library.

To Reproduce
Run this bash script on a Silicon Mac, adapting paths to conda/mamba and to sample data from GIN.

#!/usr/bin/env bash -l
mamba env remove -n brainreg-metapackage
mamba create -n brainreg-metapackage python=3.10 -y
mamba activate brainreg-metapackage
which python
which pip
python -m pip install brainglobe
which brainreg
brainreg ~/Downloads/brainreg-test-data/input/brain/ ~/Downloads/brainreg-metapackage-output/ -v 5 2 2 --orientation sal --atlas allen_mouse_25um

For me this results in:

dyld[65993]: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: <25F3C636-D4F1-34C5-BF80-7A736D353377> /Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/bin/nifty_reg/osX/reg_aladin
  Reason: tried: '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/lib/libpng16.16.dylib' (no such file), '/usr/lib/libpng16.16.dylib' (no such file, not in dyld cache)
Full relevant stack trace: ```bash subprocess.CalledProcessError: Command '/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/bin/nifty_reg/osX/reg_aladin -ln 6 -lp 5 -flo "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/brain_filtered.nii" -ref "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/downsampled_filtered.nii" -aff "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine_matrix.txt" -res "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine_registered_atlas_brain.nii" -omp 6' died with .

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/backend/niftyreg/registration.py", line 67, in register_affine
safe_execute_command(
File "/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainglobe_utils/general/system.py", line 407, in safe_execute_command
raise SafeExecuteCommandError(
brainglobe_utils.general.system.SafeExecuteCommandError:

Process failed:
dyld[65993]: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
Referenced from: <25F3C636-D4F1-34C5-BF80-7A736D353377> /Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/bin/nifty_reg/osX/reg_aladin
Reason: tried: '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/lib/libpng16.16.dylib' (no such file), '/usr/lib/libpng16.16.dylib' (no such file, not in dyld cache)


please read the logs at /Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine.log and /Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine.err

command: /Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/bin/nifty_reg/osX/reg_aladin -ln 6 -lp 5 -flo "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/brain_filtered.nii" -ref "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/downsampled_filtered.nii" -aff "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine_matrix.txt" -res "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine_registered_atlas_brain.nii" -omp 6

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/bin/brainreg", line 8, in
sys.exit(main())
File "/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/cli.py", line 288, in main
register(
File "/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/main.py", line 65, in main
run_niftyreg(
File "/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/backend/niftyreg/run.py", line 105, in run_niftyreg
brain_reg.register_affine()
File "/Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/backend/niftyreg/registration.py", line 73, in register_affine
raise RegistrationError(
brainreg.core.backend.niftyreg.registration.RegistrationError: Affine registration failed;

Process failed:
dyld[65993]: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
Referenced from: <25F3C636-D4F1-34C5-BF80-7A736D353377> /Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/bin/nifty_reg/osX/reg_aladin
Reason: tried: '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/opt/libpng/lib/libpng16.16.dylib' (no such file), '/usr/local/lib/libpng16.16.dylib' (no such file), '/usr/lib/libpng16.16.dylib' (no such file, not in dyld cache)


please read the logs at /Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine.log and /Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine.err

command: /Users/alessandrofelder/mambaforge/envs/brainreg-metapackage/lib/python3.10/site-packages/brainreg/core/bin/nifty_reg/osX/reg_aladin -ln 6 -lp 5 -flo "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/brain_filtered.nii" -ref "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/downsampled_filtered.nii" -aff "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine_matrix.txt" -res "/Users/alessandrofelder/Downloads/brainreg-metapackage-output/niftyreg/affine_registered_atlas_brain.nii" -omp 6

  
</details>


**Expected behaviour**
`brainreg` successfully runs on the sample data on Silicon Mac

**Log file**
Please attach the log file if relevant (e.g. `output/cellfinder_2019-12-17_13-29-46.log`)

**Screenshots**

\

**Computer used (please complete the following information):**

- OS: macOS
- Version: Sonoma 14.5
- Hardware specs: M2

**Additional context**
Thanks to Ritu Jacob for reporting on zulip 🙏 
@alessandrofelder alessandrofelder added the bug Something isn't working label Jun 13, 2024
@adamltyson
Copy link
Member

Assuming we can't install libpng via PyPI (?), are the options:

  • Recommend conda install and accept that PyPI won't be sufficient for macOS ARM
  • Add libpng installation instructions for macOS

Anything I'm missing?

@alessandrofelder
Copy link
Member Author

I think that's right. This also prohibits the installation of the metapackage on silicon macs.

My local experiments suggest that pip install brainglobe; conda install brainreg leads to multiple qt binaries installed that interfere with each other.

@adamltyson
Copy link
Member

Just FYI I think pip install brainglobe; conda install niftyreg does work.

@alessandrofelder
Copy link
Member Author

Do you mean conda install brainreg or niftyreg? (Our website tells Silicon mac users to install brainreg from conda-forge)

Have you tried pip install --no-cache brainglobe; conda install brainreg to mimic a "fresh" install from PyPI? I just reproduced the issue with qt binaries again locally 🤔

@adamltyson
Copy link
Member

I mean niftyreg, that should get around the qt issue, as it fetches niftyreg (and libpng), but without any qt issues.

Until the metapackage is on conda, we should probably suggest:

  • If only installing brainreg, use conda install -c conda-forge brainreg
  • If wanting to use brainreg with the metapackage, use conda install -c conda-forge niftyreg

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

No branches or pull requests

2 participants