OSError: cannot load library 'C:\Program Files\R\R-4.0.2\bin\x64\R.dll': error 0x7e

Grayson Felt

I am trying to import the rpy2 library into a Jupyter Notebook but I cannot get past this error.

The PATH 'C:\Program Files\R\R-4.0.2\bin\x64' has been added.

This is the only version of R installed on my computer. I have completely uninstalled and reinstalled R/Rstudio/Anaconda with no luck.

Here is the full error:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-7-098f0d39b3a3> in <module>
----> 1 from rpy2.robjects import pandas2ri

C:\Anaconda\lib\site-packages\rpy2\robjects\__init__.py in <module>
     14 from functools import partial
     15 import types
---> 16 import rpy2.rinterface as rinterface
     17 import rpy2.rlike.container as rlc
     18 

C:\Anaconda\lib\site-packages\rpy2\rinterface.py in <module>
      4 import typing
      5 from typing import Union
----> 6 from rpy2.rinterface_lib import openrlib
      7 import rpy2.rinterface_lib._rinterface_capi as _rinterface
      8 import rpy2.rinterface_lib.embedded as embedded

C:\Anaconda\lib\site-packages\rpy2\rinterface_lib\openrlib.py in <module>
     42     rlib = _rinterface_cffi.lib
     43 else:
---> 44     rlib = _dlopen_rlib(R_HOME)
     45 
     46 

C:\Anaconda\lib\site-packages\rpy2\rinterface_lib\openrlib.py in _dlopen_rlib(r_home)
     35         raise ValueError('The library path cannot be None.')
     36     else:
---> 37         rlib = ffi.dlopen(lib_path)
     38     return rlib
     39 

OSError: cannot load library 'C:\Program Files\R\R-4.0.2\bin\x64\R.dll': error 0x7e

edit:

Here is the code I run to import rpy2 library:

from rpy2.robjects import r, pandas2ri
Grayson Felt

1 - Windows + IDE

For those not using Anaconda, add the following in Windows' environment variables PATH:

C:\Program Files\R\R-4.0.3\bin\x64

Your R version may differ from "R-4.0.3"

2 - Anaconda

Otherwise, check Grayson Felt's reply:

I found a solution here.

Adding the PATH

C:\Users\username\Anaconda2;C:\Users\username\Anaconda2\Scripts;C:\Users\username\Anaconda2\Library\bin;C:\Users\username\Anaconda2\Library\mingw-w64\lib;C:\Users\username\Anaconda2\Library\mingw-w64\bin

and subsequently restarting Anaconda fixed the issue.

3 - Code header Windows basic

Alternatively, following Bruno's suggestion (and being more sohpisticated):

try:
    import rpy2.robjects as robjects
except OSError as e:
    try:
        import os
        import platform
        if ('Windows', 'Microsoft') in platform.system():
            os.environ["R_HOME"] = 'C:/Program Files/R/R-4.0.3/bin/x64'  # Your R version here 'R-4.0.3'
            os.environ["PATH"] = "C:/Program Files/R/R-4.0.3/bin/x64" + ";" + os.environ["PATH"]
        import rpy2.robjects as robjects
    except OSError:
        raise(e)

This code won't be effective for non-Windows platform. Also adjustments may be necessary for different R versions. If it gets more complicated than this, you should probably just go for solutions 1 or 2.

NOTE: You may also face this issue if your Python and R versions are in different architechtures (x86 vs x64)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

OSError:ライブラリ 'C:\ Program Files \ R \ R-4.0.2 \ bin \ x64 \ R.dll'を読み込めません:エラー0x7e

分類Dev

C program that displays the max of entered %2==0 numbers until you enter a number %2!=0 && %7==0

分類Dev

SQLite、ASCII文字0x20〜0x7Eチェック制約

分類Dev

Cannot load the codeigniter pagination library

分類Dev

このエラーの取得*** OSError:ライブラリC:\ WINDOWS \ libzsfc.dllを読み込めません:エラー0xc1

分類Dev

Could not load SSL library - dll not found

分類Dev

java cannot load error

分類Dev

Webpack 4 Load Library Sourcemap

分類Dev

Python - Pip Install - Proxy Error - 'Cannot connect to proxy.', OSError'

分類Dev

Deploying MVC4 application to Windows Server 2003 and IIS 7 (error 0x8007000d)

分類Dev

OSError:[Errno 0] httplib2リクエストのエラー

分類Dev

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Users\\Public\\xampp\\php\\ext\\php_sqlsrv_56_ts.dll'

分類Dev

C Program Compilation issue involving Glib2 library?

分類Dev

JNIConnector.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform Skype4java

分類Dev

Message error 'C:/Program' not found with glmmadmb() in R

分類Dev

Visual Studio 2012: Component dll failed to load unable to start program

分類Dev

Cの{0,1,2,3,4,5,6,7,8,9}以外の条件

分類Dev

0x742808F2での未処理の例外:Microsoft C ++例外:メモリ位置0x0055E9E4のstd :: out_of_range

分類Dev

php_oci8.dll - Unable to load dynamic library

分類Dev

DllNotFoundException: Unable to load DLL 'librvnpal' when starting RavenDB 4.2 on windows 7 x64. How to correct this?

分類Dev

c++ Exception thrown at 0x7A45FF80 (ucrtbased.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x00000000

分類Dev

SIGBRT Error : Could not cast value of type 'UITableViewController' (0x113ccb7e0) to 'Racing_Weather.PredictorTableViewController' (0x1086645b0)

分類Dev

PHP Warning: PHP Startup: Unable to load dynamic library '- The specified procedure could not be found. in Unknown on line 0

分類Dev

0x50E2DF58(msvcp120d.dll)で未処理の例外

分類Dev

C++ DLL fails to load on some machines

分類Dev

Attempt to load library; get "bad image" error

分類Dev

Cannot load mkl_intel_thread.dll on python executable

分類Dev

Accelerated C++ Exercise 4-0

分類Dev

ARRAY(0x7ff4bbb0c7b8)エラー:配列のperlハッシュ

Related 関連記事

  1. 1

    OSError:ライブラリ 'C:\ Program Files \ R \ R-4.0.2 \ bin \ x64 \ R.dll'を読み込めません:エラー0x7e

  2. 2

    C program that displays the max of entered %2==0 numbers until you enter a number %2!=0 && %7==0

  3. 3

    SQLite、ASCII文字0x20〜0x7Eチェック制約

  4. 4

    Cannot load the codeigniter pagination library

  5. 5

    このエラーの取得*** OSError:ライブラリC:\ WINDOWS \ libzsfc.dllを読み込めません:エラー0xc1

  6. 6

    Could not load SSL library - dll not found

  7. 7

    java cannot load error

  8. 8

    Webpack 4 Load Library Sourcemap

  9. 9

    Python - Pip Install - Proxy Error - 'Cannot connect to proxy.', OSError'

  10. 10

    Deploying MVC4 application to Windows Server 2003 and IIS 7 (error 0x8007000d)

  11. 11

    OSError:[Errno 0] httplib2リクエストのエラー

  12. 12

    PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Users\\Public\\xampp\\php\\ext\\php_sqlsrv_56_ts.dll'

  13. 13

    C Program Compilation issue involving Glib2 library?

  14. 14

    JNIConnector.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform Skype4java

  15. 15

    Message error 'C:/Program' not found with glmmadmb() in R

  16. 16

    Visual Studio 2012: Component dll failed to load unable to start program

  17. 17

    Cの{0,1,2,3,4,5,6,7,8,9}以外の条件

  18. 18

    0x742808F2での未処理の例外:Microsoft C ++例外:メモリ位置0x0055E9E4のstd :: out_of_range

  19. 19

    php_oci8.dll - Unable to load dynamic library

  20. 20

    DllNotFoundException: Unable to load DLL 'librvnpal' when starting RavenDB 4.2 on windows 7 x64. How to correct this?

  21. 21

    c++ Exception thrown at 0x7A45FF80 (ucrtbased.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x00000000

  22. 22

    SIGBRT Error : Could not cast value of type 'UITableViewController' (0x113ccb7e0) to 'Racing_Weather.PredictorTableViewController' (0x1086645b0)

  23. 23

    PHP Warning: PHP Startup: Unable to load dynamic library '- The specified procedure could not be found. in Unknown on line 0

  24. 24

    0x50E2DF58(msvcp120d.dll)で未処理の例外

  25. 25

    C++ DLL fails to load on some machines

  26. 26

    Attempt to load library; get "bad image" error

  27. 27

    Cannot load mkl_intel_thread.dll on python executable

  28. 28

    Accelerated C++ Exercise 4-0

  29. 29

    ARRAY(0x7ff4bbb0c7b8)エラー:配列のperlハッシュ

ホットタグ

アーカイブ