An error occurred when calling lavaan with rpy2.

79 views
Skip to first unread message

Wojuer

unread,
Jul 30, 2019, 9:44:43 PM7/30/19
to lavaan
Dear list,

I tried to use python for validity analysis, so I used rpy2 to call the lavaan package in R for calculation. When I call other packages of R, I can display success. Only the lavaan package can't run. What should I do if you have this situation?  Code show as below:


[In]:    from rpy2.robjects.packages import importr
         lavaan = importr('lavaan')

[Out]:   ---------------------------------------------------------------------------
RRuntimeError                             Traceback (most recent call last)
<ipython-input-93-71e6d20e5e18> in <module>
     
1 from rpy2.robjects.packages import importr
----> 2 lavaan = importr('lavaan')

C
:\ProgramData\Anaconda3\lib\site-packages\rpy2\robjects\packages.py in importr(name, lib_loc, robject_translations, signature_translation, suppress_messages, on_conflict, symbol_r2python, symbol_check_after, data)
   
451     if _package_has_namespace(rname,
   
452                               _system_file(package = rname)):
--> 453         env = _get_namespace(rname)
   
454         version = _get_namespace_version(rname)[0]
   
455         exported_names = set(_get_namespace_exports(rname))

RRuntimeError:






Any help would be much appreciated.

Jeremy Miles

unread,
Jul 31, 2019, 1:03:25 PM7/31/19
to lav...@googlegroups.com
This looks to me like a problem with python, not lavaan.

The error is being thrown in this file: http://rpy.sourceforge.net/rpy2/doc-2.4/html/_modules/rpy2/robjects/packages.html (it appears), at the line that says:

env = _get_namespace(rname)
Further up, it says:
_get_namespace = rinterface.baseenv['getNamespace']
So that's not working. The python package maintainer might be able to help. You might want to say what the runtime error actually is. 

Jeremy




--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/b31e8d94-06e4-4728-87cc-86fe2bac0af0%40googlegroups.com.

Wojuer

unread,
Aug 1, 2019, 2:18:52 AM8/1/19
to lavaan
Thank you for your answer,In my case, when I use Rpy2 to call the R package, most of the packages can be successfully called. There are some packages that can't be called before. The result is the same as the above, but when I will package After the folder is copied in the library under Anaconda, it can be called successfully, but lavaan and sem are still called in this way, so I want to know how to call lavaan successfully.

在 2019年8月1日星期四 UTC+8上午1:03:25,Jeremy Miles写道:
To unsubscribe from this group and stop receiving emails from it, send an email to lav...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages