我正在使用以下代码创建conda环境
conda create --prefix r_venv_conda r=3.3 r-essentials r-base --y
然后我将通过以下方式激活这个env
conda activate r_venv_conda/
然后我尝试运行朱庇特笔记本(通过运行jupyter notebook
运行Jupyter,希望这将连接run )。但是,我收到了以下错误
Traceback (most recent call last):
File "/home/Documents/project/r_venv_conda/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/home/Documents/project/r_venv_conda/lib/python3.6/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/home/Documents/project/r_venv_conda/lib/python3.6/site-packages/notebook/nbextensions.py", line 26, in <module>
from .config_manager import BaseJSONConfigManager
File "/home/Documents/project/r_venv_conda/lib/python3.6/site-packages/notebook/config_manager.py", line 14, in <module>
from traitlets.config import LoggingConfigurable
File "/home/Documents/project/r_venv_conda/lib/python3.6/site-packages/traitlets/config/__init__.py", line 6, in <module>
from .application import *
File "/home/Documents/project/r_venv_conda/lib/python3.6/site-packages/traitlets/config/application.py", line 38, in <module>
import api.helper.background.config_related
ModuleNotFoundError: No module named 'api'
我怎样才能解决这个问题?
发布于 2020-04-29 17:59:16
木星不自动识别Conda环境,激活与否。
核模块
首先,要使环境作为内核运行,必须安装适当的内核包。对于R环境,即r-irkernel
,因此需要运行
conda install -n r_venv_conda r-irkernel
对于Python,它是ipykernel
。
内核注册
第二,内核需要在木星上注册。如果通过Conda安装了木星(例如在Anaconda base env中),那么我建议使用套餐,它可以自动发现内核就绪的Conda环境。这必须安装在安装了jupyter
的环境中(只需要一个安装!),例如,如果这是base,那么
conda install -n base nb_conda_kernels
如果使用木星的系统级安装(即,没有由Conda安装),那么需要手动注册内核。例如,类似于
conda run -n r_venv_conda Rscript -e 'IRkernel::installspec(name="ir33", displayname="R 3.3")'
其中可以为name
和displayname
设置任意值。详细信息请参见IRkernel。
运行木星
如果使用Conda安装的木星,那么它只需要安装在一个env中。这是在运行jupyter notebook
之前应该激活的环境。内核可以在木星内部进行选择。
发布于 2021-11-16 17:29:20
我发现最好的方法是
conda create -n viper r python=3.8.8 #check your conda python version
conda activate viper
conda install -c r r-essentials
这将设置那些有用的r包,您可以在以后安装更多。让他们进入r-内核。
发布于 2021-12-17 22:49:18
我使用以下bash命令创建R环境并将其连接到jupyter会话:
# 1. pick a name for the conda environment
name='r_env'
# 2. create the environment
conda create -n $name r-essentials r-base
# 3. install `irkernel` and `devtools` for `IRkernel/repr`
conda install -c conda-forge r-devtools r-irkernel
# 4. setup `irkernel`
Rscript -e 'IRkernel::installspec(name="$name", displayname="$name")'
# 4. install and setup `IRkernel/repr` (for displaying help messages in jupyter)
Rscript -e 'devtools::install_github("IRkernel/repr")'
https://stackoverflow.com/questions/61494376
复制相似问题