![](/img/trans.png)
[英]R: Error in library(affy): Error: package or namespace load failed for ‘affy’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared objec
[英]Error: package or namespace load failed for ‘gmm’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object
我已經上傳了R的版本到4.0.2(2020-06-22)。 在我需要安裝 gmm package 后,我收到了以下消息。 我還為其他軟件包(如 TropFishR)獲取了此消息。 我有 Xcode 10.3。 我重新安裝了 R studio 和 R 幾次。 非常感謝您的寶貴時間。
錯誤信息:
Error: package or namespace load failed for ‘gmm’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so, 6): Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so
Reason: image not found
session info:
version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] sandwich_2.5-1
loaded via a namespace (and not attached):
[1] zoo_1.8-8 compiler_4.0.2
[3] tools_4.0.2 grid_4.0.2
[5] lattice_0.20-41
該問題是由於Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib
丟失。
為了解決這個問題,我去了這個Github 發布頁面,下載gfortran-10.2-Catalina.dmg
並安裝了它。 然后我終於可以在R中加載gmm
package。
在 MacOS 13 上,下載此文件,並在/opt/R/arm64/gfortran/lib
中構建到/usr/local/gfortran/lib/libgomp.1.dylib
的硬鏈接,例如,使用以下命令:
sudo ln libgomp.1.dylib /opt/R/arm64/gfortran/lib/libgomp.1.dylib
也許目錄/gfortran/lib
需要手動構建。 希望有幫助~
使用這個答案,我找到了一種(臨時)方法來解決這個問題,而不會弄亂安裝。
該程序似乎找不到libgomp.1.dylib
,但是,您的系統可能已經安裝了此文件。 使用
locate libgomp.1.dylib
你會得到一個找到這個圖書館的地方的列表。 如果您是第一次運行此命令,您可能必須先運行另一個命令來創建索引。
對我來說,這是
/usr/local/Cellar/gcc/12.1.0/lib/gcc/current/libgomp.1.dylib
但是,在您的系統上可能會有所不同。
如果沒有返回,您可能需要在系統上安裝gfortran
,例如使用brew install gcc
。
我的錯誤消息向我顯示了它試圖查找文件的一些地方,其中一個在我的用戶目錄中:
/Users/overground/lib
因此,使用ln
創建從該目錄到您在上一步中找到的文件的鏈接。 首先,確保lib
文件夾存在於您的用戶目錄中。 然后,將文件與
ln /usr/local/Cellar/gcc/12.1.0/lib/gcc/current/libgomp.1.dylib /Users/overground/lib
將第一個文件路徑替換為您在第一步中找到的文件路徑,以及第二個路徑中的用戶名。 現在,您應該能夠在lib
目錄中看到該文件。
我希望這有幫助!
這聽起來很瘋狂,但我在運行我編寫的 bash 腳本(比如 masterPipeline.sh)時遇到了同樣的問題。 當我編寫該腳本時它工作正常,但是幾天前我收到此錯誤:
Error: package or namespace load failed for ‘stats’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/hemiptero/lib/R/library/stats/libs/stats.so':
問題是在 masterPipeline.sh 調用 R 來創建子例程 (R <./scripts/measure2sd.r --no-save) 之后出現的,但是當我自己在終端中鍵入該命令時,我沒有收到錯誤。
所以,我不知道如何,但我想到了以超級用戶身份運行我的腳本。
sudo masterPipeline.sh
有用!
所以也許以超級用戶身份運行 R 對那些在 linux 上工作的人有用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.