在HPC平台上跑我的R语言代码,结果一直报错说:
Error in py_run_file_impl(file, local, convert) : ModuleNotFoundError: No module named 'igraph'
我就知道是我R语言里面导入python包那里出现了问题,对应的python环境没有这个包,我进入了R环境,使用命令如下:
library(reticulate)
py_module_available(“igraph”)#返回了False
conda_list()
name
1 0
2 mofa_env
3 DCCA_env
4 babel
5 d2l-zh
6 deepmaps_env
7 deepmaps_env_
8 py3
9 py3.8_R4
10 scMVAE_env
11 scvi-env
12 base
13 r-reticulate
python
1 /public/home/hpc/.cache/R/basilisk/1.6.0/0/bin/python
2 /public/home/hpc/.cache/R/basilisk/1.6.0/MOFA2/1.4.0/mofa_env/bin/python
3 /public/home/hpc/.conda/envs/DCCA_env/bin/python
4 /public/home/hpc/.conda/envs/babel/bin/python
5 /public/home/hpc/.conda/envs/d2l-zh/bin/python
6 /public/home/hpc/.conda/envs/deepmaps_env/bin/python
7 /public/home/hpc/.conda/envs/deepmaps_env_/bin/python
8 /public/home/hpc/.conda/envs/py3/bin/python
9 /public/home/hpc/.conda/envs/py3.8_R4/bin/python
10 /public/home/hpc/.conda/envs/scMVAE_env/bin/python
11 /public/home/hpc.conda/envs/scvi-env/bin/python
12 /public/home/hpc.local/share/r-miniconda/bin/python
13 /public/home/hpc/.local/share/r-miniconda/envs/r-reticulate/bin/python
use_condaenv(“r-reticulate”)#指定虚拟环境
py_config()
python:
/public/home/hpc/.local/share/r-miniconda/envs/r-reticulate/bin/python
libpython:
/public/home/hpc/.local/share/r-miniconda/envs/r-reticulate/lib/libpython3.8.so
pythonhome:
/public/home/hpc/.local/share/r-miniconda/envs/r-reticulate:/public/home/hpc/.local/share/r-miniconda/envs/r-reticulate
version: 3.8.13 | packaged by conda-forge | (default, Mar 25
2022, 06:04:18) [GCC 10.3.0] numpy:
/public/home/hpc/.local/share/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/numpy
numpy_version: 1.23.0
此时我已经知道了我应该往哪个虚拟环境里面安装igraph包,就是 /public/home/hpc/.local/share/r-miniconda/envs/r-reticulate/
进入此虚拟环境后,pip install igraph
即可,继续提交我的R任务,成功出结果!!!