Jupyter和Conda:克隆环境时出错

Chiaka

为了测试已安装软件包的兼容性,我创建了多个conda环境。conda create -n test02 --clone test01用来创建环境test02作为test01的克隆。我激活test02,安装新软件包并启动python实例,从该实例中导入新软件包没有问题。当我启动jupyter笔记本电脑或qtconsole并尝试导入新安装的程序包并获得导入错误:没有名为“ xxx”的模块时,就会出现问题。我做了一个sys.executable,发现jupyter从旧环境(test01)运行python,我从中克隆了新环境。为什么会这样呢?我可以在某个地方的配置文件中更改它吗?在哪里可以找到此文件?

编辑:更多信息

jupyter --paths 这两个环境在同一环境目录中共享配置和数据的路径条目

(test01) PS C:\Users\Aka> jupyter --paths
config:
    C:\Users\Aka\.jupyter
    c:\users\aka\miniconda3\envs\test01\etc\jupyter
    C:\ProgramData\jupyter
data:
    C:\Users\Aka\AppData\Roaming\jupyter
    c:\users\aka\miniconda3\envs\test01\share\jupyter
    C:\ProgramData\jupyter
runtime:
    C:\Users\Aka\AppData\Roaming\jupyter\runtime
(test01) PS C:\Users\Aka> conda activate test02
(test02) PS C:\Users\Aka> jupyter --paths
config:
    C:\Users\Aka\.jupyter
    c:\users\aka\miniconda3\envs\test01\etc\jupyter
    C:\ProgramData\jupyter
data:
    C:\Users\Aka\AppData\Roaming\jupyter
    c:\users\aka\miniconda3\envs\test01\share\jupyter
    C:\ProgramData\jupyter
runtime:
    C:\Users\Aka\AppData\Roaming\jupyter\runtime

edit2:我忘了提到我使用pip安装了Jupyter。

重现我所做的问题:

conda create -n env1
conda activate env1
pip install jupyter
jupyter --paths

配置:
C:\ Users \ Aka.jupyter
c:\ users \ aka \ miniconda3 \ envs \ env1 \ etc \ jupyter
C:\ ProgramData \ jupyter
数据:
C:\ Users \ Aka \ AppData \ Roaming \ jupyter
c:\ users \ aka \ miniconda3 \ envs \ env1 \ share \ jupyter
C:\ ProgramData \ jupyter
运行时:
C:\ Users \ Aka \ AppData \ Roaming \ jupyter \ runtime

conda create --clone env1 -n env2
conda activate env2
jupyter --paths

配置:
C:\ Users \ Aka.jupyter
c:\ users \ aka \ miniconda3 \ envs \ env1 \ etc \ jupyter
C:\ ProgramData \ jupyter
数据:
C:\ Users \ Aka \ AppData \ Roaming \ jupyter
c:\ users \ aka \ miniconda3 \ envs \ env1 \ share \ jupyter
C:\ ProgramData \ jupyter
运行时:
C:\ Users \ Aka \ AppData \ Roaming \ jupyter \ runtime

如果我要将带有conda的jupyter安装到全新的环境中,然后克隆该环境,jupyter的行为将与预期的一样。注意:我使用pip安装了jupyter,因为我使用的是python 3.5,因为我需要其他软件包,因此在我的环境中使用conda安装jupyter时会不断破坏它。我伸出手去向conda-forge寻求帮助,但他们说“对不起,我们不支持python 3.5”。

梅尔

Jupyter只需要安装在一个位置即可-Conda env或系统级。

安装在Conda env中的Jupyter

要将其他env用作内核,需要使用Jupyter将其安装nb_conda_kernels在env中,以及ipykernel您希望用作内核的任何env中。始终jupyter notebook使用Jupyter从环境启动,其他将自动可用。

Jupyter在Conda之外

如果Jupyter是在系统级别安装的,则必须手动注册一个希望用作内核的Conda env:

conda activate my_env
conda install ipykernel
python -m ipykernel install --user --name my_env_name

然后从任何地方启动Jupyter。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用conda克隆环境时发生异常

来自分类Dev

使用conda克隆环境时发生异常

来自分类Dev

Conda环境和Jupyter Notebook,Python 3.9.2

来自分类Dev

Conda环境和Jupyter Notebook,Python 3.9.2

来自分类Dev

在气密机器上克隆Conda环境

来自分类Dev

激活conda环境后,jupyter笔记本和ipython的路径不正确

来自分类Dev

在conda环境中在Raspberry Pi 4上安装熊猫时出错

来自分类Dev

将Conda环境与Jupyter Notebook链接

来自分类Dev

在Jupyter Notebook中使用conda环境

来自分类Dev

Jupyter Notebook内核与Conda环境不同

来自分类Dev

Conda环境和.BAT文件

来自分类Dev

激活环境时Conda中断-CommandNotFoundError:无命令'conda conda'

来自分类Dev

使用ssh克隆git仓库时出错

来自分类Dev

使用ssh克隆git仓库时出错

来自分类Dev

使用Cat克隆磁盘时出错

来自分类Dev

如何在conda环境中用克隆的GitHub版本替换libprotobuf的conda软件包

来自分类Dev

创建新的Conda环境时出现PackageNotFoundError

来自分类Dev

如何在conda创建的环境中启动jupyter?

来自分类Dev

在所有 Conda 环境中都需要 Jupyter 密码

来自分类Dev

conda 虚拟环境中的 Jupyter 魔术命令 %%time 错误

来自分类Dev

Conda环境和Jupiter Notebook,Python 3.9.2

来自分类Dev

关于点和conda环境的困惑

来自分类Dev

Microsoft SQL Server 2017 和 conda 环境

来自分类Dev

构建conda的R-packages时出错

来自分类Dev

启动Elastic Beanstalk环境时出错

来自分类Dev

返回环境帐户ID时出错

来自分类Dev

创建环境变量时出错

来自分类Dev

导入pyqtgraph jupyter notebook时出错

来自分类Dev

错误:克隆远程存储库“源”时出错