Mac 10.13.1(High Sierra)下Studio中Imager包无法使用求助
Hey there, let's work through this issue since your functionality was working perfectly before installing the imager package. The "image not found" error can stem from a few common spots—here are the steps to diagnose and fix it:
Verify the imager package installation completed successfully
Sometimes package installs can fail silently or miss critical dependencies. Try reinstalling the package to rule this out:- For the CRAN version:
install.packages("imager", dependencies = TRUE) - For the development version:
devtools::install_github("ropensci/imager")
Keep an eye on the console during installation—if there are error messages about missing system libraries, that’s a key clue to follow up on.
- For the CRAN version:
Check for missing system-level dependencies
Imager relies on underlying system libraries to process image files. Depending on your operating system, you might need to install these first:- Ubuntu/Debian: Run
sudo apt-get install libpng-dev libjpeg-dev libtiff-dev libfftw3-dev - macOS: Use Homebrew to install
brew install libpng jpeg libtiff fftw - Windows: Ensure Rtools is installed and properly configured (it should be detected automatically when installing source packages)
- Ubuntu/Debian: Run
Confirm your image file path is valid
The error might not be with the package itself, but with how you’re referencing your image. Try these checks:- Run
file.exists("path/to/your/image.png")—if this returnsFALSE, your path is incorrect (double-check typos or relative vs. absolute path issues). - Test with an absolute path instead of a relative one to eliminate working directory confusion. For example:
load.image("/Users/yourname/Documents/test_image.jpg")
- Run
Test in a clean R session
It’s possible another package is conflicting with imager. Restart R, don’t load any other packages, then run a simple test with a sample image included in the package:library(imager) sample_img <- load.image(system.file("extdata/Leonardo_Birds.jpg", package = "imager")) plot(sample_img)If this works, the issue is likely a conflict with another package you usually load.
Check version compatibility
Outdated versions of R or imager can cause unexpected errors. Make sure you’re running a recent R version (3.6.0 or newer is recommended for imager), and that you have the latest version of the imager package installed.
内容的提问来源于stack exchange,提问作者emeric lemaire

