[英]Unable to import rpy2, VSCode in WSL windows subsytem for linux
Looking for help on using rpy2 in python script with vscode from WSL.寻找有关在 python 脚本中使用 rpy2 和来自 WSL 的 vscode 的帮助。 I can't get the import to work.
我无法让导入工作。
If i try to run the following code:如果我尝试运行以下代码:
import rpy2
print(rpy2.__version__)
I get the following AttributeError:我得到以下属性错误:
AttributeError: partially initialized module 'rpy2' has no attribute '__version__' (most likely due to a circular import)
If I try to import rpy2.rpackages
, I get the following error:如果我尝试
import rpy2.rpackages
,我会收到以下错误:
ModuleNotFoundError: No module named 'rpy2.rpackages'; 'rpy2' is not a package
I have successfully installed rpy2 through the bash terminal on VSCode with pip as shown in the below screenshot:我已经通过 VSCode 上的 bash 终端使用 pip 成功安装了 rpy2,如下面的屏幕截图所示:
There is no module or sub-package rpackages
in rpy2, so the error message when trying to import it is expected. rpy2 中没有模块或子包
rpackages
,因此在尝试导入时会出现错误消息。
The error about a circular a partially initialized module is surprising.关于循环部分初始化模块的错误令人惊讶。 Do you happen to have a directory called
rpy2
where you are running this from?您是否碰巧有一个名为
rpy2
的目录,您从中运行它? Python would try to import that directory. Python 会尝试导入该目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.