How to install libpng-dev on Mac
Asked Answered
M

2

6

I am trying to install the reticulate package on my Mac and it depends on the png package, which in turn depends on libpng. I installed libpng with brew but the png package fails due to a missing libpng-config:

/bin/sh: libpng-config: command not found

However I have this in /opt/homebrew/bin/libpng-config:

which libpng-config
/opt/homebrew/bin/libpng-config

I found this that specifies the need for libpng-dev but I have no idea how to install that on my Mac. Any help is appreciated.

Marcusmarcy answered 20/1, 2022 at 16:0 Comment(1)
I tried with the following error: Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’ (as ‘lib’ is unspecified) Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror Calls: install.packages -> startsWith -> contrib.url Execution haltedMarcusmarcy
C
4

Processes not started from a shell may not inherit environment variables from that shell. Start R in Terminal to make sure that your R process inherits PATH from the Terminal shell where you have run which. Something like

$ Rscript -e "install.packages(\"png\")"

should work, though you may need to select a CRAN mirror, in which case the above will throw an error. You can do that in the install.packages call, like so:

$ Rscript -e "install.packages(\"png\", repos = \"https://cloud.r-project.org\")"

or by setting a global option, like so:

$ Rscript -e "options(repos = \"https://cloud.r-project.org\"); install.packages(\"png\")"

For details, see the R for macOS FAQ and ?options.

Cordova answered 20/1, 2022 at 17:17 Comment(0)
C
0

After installing libpng

brew install libpng

check the path

brew --prefix libpng

Try this first (if you are using zsh):
Export path to your .zshrc file and reload

echo 'export PATH="/opt/homebrew/opt/libpng/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

If that does not work (it did not for me!), this symlink did the trick:

ln -s /opt/homebrew/opt/libpng/bin/libpng-config /usr/local/bin/libpng-config
Concertize answered 17/10 at 22:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.