jupyter kernelspec 没有这样的文件或目录 /lib/libstdc++.so.6.0.21

jupyter kernelspec no such file or directory /lib/libstdc++.so.6.0.21

在用户创建环境并希望与其他用户共享的情况下,我正在尝试充实 JupyterHub 服务器的工作流程。我想测试两种方法中的一种。

我正在尝试在 public 路径中创建一个环境,然后让另一个用户将 conda 环境添加为内核。到目前为止它看起来像这样。

# How the environment is created
jupyter@ip:~$ conda create -p /home/envs/test --clone root

# Current setup
nick {~}$ jupyter kernelspec list
Available kernels:
  python3    /opt/conda/share/jupyter/kernels/python3
nick {~}$ conda env list
# conda environments:
#
test                     /home/envs/test
nenv                     /home/nick/.conda/envs/nenv
base                  *  /opt/conda

nick {~}$ cat .condarc
envs_dirs:
  - /home/envs

我的问题是当我尝试安装内核时出现错误 libstdc++.so.6.0.21 不存在。什么是 libstdc++.so.6.0.21

# error when trying to install kernel
nick {~}$ jupyter kernelspec install --user /home/envs/test
[InstallKernelSpec] Removing existing kernelspec in /home/nick/.local/share/jupyter/kernels/test
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-kernelspec", line 11, in <module>
    sys.exit(KernelSpecApp.launch_instance())
  File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/opt/conda/lib/python3.7/site-packages/jupyter_client/kernelspecapp.py", line 273, in start
    return self.subapp.start()
  File "/opt/conda/lib/python3.7/site-packages/jupyter_client/kernelspecapp.py", line 143, in start
    replace=self.replace,
  File "/opt/conda/lib/python3.7/site-packages/jupyter_client/kernelspec.py", line 346, in install_kernel_spec
    shutil.copytree(source_dir, destination)
  File "/opt/conda/lib/python3.7/shutil.py", line 365, in copytree
    raise Error(errors)
shutil.Error: [('/home/envs/test/lib/libstdc++.so.6.0.21', '/home/nick/.local/share/jupyter/kernels/test/lib/libstdc++.so.6.0.21', "[Errno 2] No such file or directory: '/home/envs/test/lib/libstdc++.so.6.0.21'")]

注意:I found this question which is similar; however, I found through this github thread 为什么必须删除 gcc,我已经通过以下方式验证它在我的环境中不存在:

nick {~}$ conda list --name test | grep 'gcc'
_libgcc_mutex             0.1                        main  
libgcc                    7.2.0                h69d50b8_2  
libgcc-ng                 8.2.0                hdf63c60_1

我已经安装了更高版本的 libgcc,正如您在上面看到的,所以我认为其他答案也不会有太大好处。


文件名显示为红色,所以我认为 link 已损坏。

(test) nick {~}$ ls -al /home/envs/test/lib/libstdc++.so.6.0.21
lrwxrwxrwx 1 jupyter jupyter 19 Aug  9 09:42 /home/envs/test/lib/libstdc++.so.6.0.21 -> libstdc++.so.6.0.24

我意识到我以非预期的方式使用了 jupyter kernelspec here. It is not intended to actually create the kernel, but only to add a kernelspec if it exists (see here, at the bottom)

There are two options for writing a kernel:

  1. You can reuse the IPython kernel machinery to handle the communications, and just describe how to execute your code. This is much simpler if the target language can be driven from Python. See Making simple Python wrapper kernels for details.
  2. You can implement the kernel machinery in your target language. This is more work initially, but the people using your kernel might be more likely to contribute to it if it’s in the language they know.

所以,在我的情况下,我真正想做的是使用 IPython 实用程序(上面的选项 1)which is documented well here. 在这种情况下,以用户可以访问的方式将共享的 conda 环境添加为内核我只需要 运行.

su - <user>
conda activate test
python -m ipykernel install --user --name test --display-name "Python (test)"