Loading Packages

Hi all,

I am very, very new to R so excuse my ignorance.

I am having difficultly loading packages. I've read through previous threads providing information on this but I haven't found a solution yet.

I get the following message when trying to load previously installed packages.

library("IsingFit")
Error: package or namespace load failed for ‘IsingFit’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so, 6): Symbol not found: _inflateValidate
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libz.1.dylib
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/png/libs/png.so

Any help would be greatly appreciated.

Thank you!

In macOS it's preferable to decline the option to install the later version from source. The error message /usr/lib/libz.1.dylib is either corrupted or missing. That can be fixed but it requires optional tools and understanding of compiling programs.

Thanks for your response technocrat. Do you have any recommendations on how to fix the corrupted file?

Thanks

I think it's more likely to be missing than corrupted.

R packages come either pre-compiled (binary) or in source code(source). There is hardly any issue with the binary; for source there often can be because Apple uses some non-standard software that requires the source code to be edited.

I've been compiling my own and others' source code for almost 40 years. I don't attempt to install macOS from source more than once: if it doesn't run the first time it takes far more time than it is worth to me to debug. Fortunately, St. Simon Urbanek at the R Foundation relieves us from this difficulty by doing the hard work to make a binary.

Did you see the message when you tried to install about "a binary version is available but the source code is later"? Try again, and this time answer "N".

If that doesn't work, come back and we'll run you through setting up your macOS to compile programs

I think I have the same issue. Wondering if it's something to do with the png package itself?

When I try to load the package I need which imports png (Hmisc), I get this message.

> library(Hmisc)
Loading required package: Formula
Loading required package: ggplot2
Error: package or namespace load failed for ‘Hmisc’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/harlyjanedurbin/Library/R/4.0/library/png/libs/png.so':
  dlopen(/Users/harlyjanedurbin/Library/R/4.0/library/png/libs/png.so, 6): Symbol not found: _inflateValidate
  Referenced from: /Users/harlyjanedurbin/Library/R/4.0/library/png/libs/png.so (which was built for Mac OS X 10.13)
  Expected in: /usr/lib/libz.1.dylib
 in /Users/harlyjanedurbin/Library/R/4.0/library/png/libs/png.so

I've tried un-installing and re-installing both png and Hmisc and can do so without error.

> remove.packages("png")
Removing package from ‘/Users/harlyjanedurbin/Library/R/4.0/library’
(as ‘lib’ is unspecified)
> install.packages("png")
Installing package into ‘/Users/harlyjanedurbin/Library/R/4.0/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/png_0.1-7.tgz'
Content type 'application/x-gzip' length 369557 bytes (360 KB)
==================================================
downloaded 360 KB


The downloaded binary packages are in
	/var/folders/7h/_xszd0lx7wzctr3r7zhc3hs40000gn/T//Rtmpx9yVN8/downloaded_packages
> remove.packages("Hmisc")
Removing package from ‘/Users/harlyjanedurbin/Library/R/4.0/library’
(as ‘lib’ is unspecified)
> install.packages("Hmisc")
Installing package into ‘/Users/harlyjanedurbin/Library/R/4.0/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/Hmisc_4.4-1.tgz'
Content type 'application/x-gzip' length 3144200 bytes (3.0 MB)
==================================================
downloaded 3.0 MB


The downloaded binary packages are in
	/var/folders/7h/_xszd0lx7wzctr3r7zhc3hs40000gn/T//Rtmpx9yVN8/downloaded_packages

But no luck. Even tried uninstalling Anaconda based on this old post: https://stackoverflow.com/questions/47424249/unable-to-install-the-package-png-on-r-possible-conflict-with-anaconda/50935430

If it makes a difference, I didn't have issues with these packages until I updated to R v4 last night :sweat: any ideas?

Should add that I installed GNU Fortran 8.2 like suggested when I updated R last night

Anaconda is a fabulous package manager. For Python, not so much for R.

My recommendation is to uninstall the current version of R, reinstall from CRAN and then the packages. It will help if you send Anaconda to the back of your $PATH.

Check back if you have problems.

Thanks technocrat. I uninstalled and reinstalled packages but I didn't receive the message "a binary version is available but the source code is later" :frowning:

Are you still using the Anaconda package manager?

I don't think so. I apologise for my complete ignorance.

We all start at zero. To advance on this sticking point use the menubar Tools | Install Packages dialog box in RStudio

Click into the console window if it pauses for the question about later versions and answer n

Okay. Perfect done. I didn't receive a question about the later versions though :slight_smile:

1 Like

Great! You won't always get the dialog, so that's normal. Go crunch data.

Unfortunately, I am still receiving the message when I try to load 'IsingFit' ...

So, you installed the same way as with Hmisc and there was no prompt about source version?

No unfortunately there wasn't ...

OK, let's do it the harder way, after first trying from the terminal in RStudio or from the R app in Applications

install.packages("IsingFit")

On my Airbook it installs without an error. I suspect it won't on yours.

To minimize possible sources of the error, it will help to be on a relatively recent version of Catalina, the current version of XCode and to enable the command line tools.

xcode-select --install

Try install.packages again. If it doesn't work, make sure your XQuartz is up-to-date and that you installed the notarized R packages as shown on the screenshot. I'll check back in the forenoon Seattle time.

I reset my computer and re downloaded R, R studio and XQyartz. I installed IsingFit again. I got following message 'There is a binary version available but the source version in later: binary source needs_complication back ports 1.18 1.19 TRUE. Do you want to install from sources the pack which needs complication? (yes/no/cancel)' - I responded n and downloaded 'IsingFit'. However, I received the exact same message when I went to load the package library(IsingFit)

That's progress. Is there a file

/Users/harlyjanedurbin/Library/R/4.0/library/png/libs/png.so

I'll check on my Airbook, also

I have it in the comparable location. I last updated it in April and no further update is available for `update.packages("png")