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.

Hahnemann
  • 4,378
  • 6
  • 40
  • 64
  • 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 halted – Hahnemann Jan 20 '22 at 16:51

1 Answers1

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.

Mikael Jagan
  • 9,012
  • 2
  • 17
  • 48