Hahnemann
Hahnemann

Reputation: 4648

How to install libpng-dev on Mac

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.

Upvotes: 6

Views: 4612

Answers (2)

Henrik
Henrik

Reputation: 1151

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

Upvotes: 0

Mikael Jagan
Mikael Jagan

Reputation: 11306

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.

Upvotes: 4

Related Questions