1

我正在尝试通过 SSH 在先前在直接登录的计算机上创建的 virtualenv 中运行 ipython notebook(无 SSH)。这样做时,ipython notebook 失败并显示:

(venv2) [host]user: ipython notebook --nobrowser

Traceback (most recent call last):
  File ".../venv2/bin/ipython", line 11, in <module>
    sys.exit(start_ipython())
  File ".../venv2/lib/python2.7/site-packages/IPython/__init__.py", line 118, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File ".../venv2/lib/python2.7/site-packages/traitlets/config/application.py", line 591, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-111>", line 2, in initialize
  File ".../venv2/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File ".../venv2/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 305, in initialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File ".../venv2/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File ".../venv2/lib/python2.7/site-packages/IPython/core/application.py", line 386, in initialize
    self.parse_command_line(argv)
  File ".../venv2/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 300, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<decorator-gen-4>", line 2, in parse_command_line
  File ".../venv2/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File ".../venv2/lib/python2.7/site-packages/traitlets/config/application.py", line 487, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<decorator-gen-3>", line 2, in initialize_subcommand
  File ".../venv2/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File ".../venv2/lib/python2.7/site-packages/traitlets/config/application.py", line 418, in initialize_subcommand
    subapp = import_item(subapp)
  File ".../venv2/lib/python2.7/site-packages/ipython_genutils/importstring.py", line 31, in import_item
    module = __import__(package, fromlist=[obj])
  File ".../venv2/lib/python2.7/site-packages/notebook/notebookapp.py", line 32, in <module>
    from zmq.eventloop import ioloop
  File ".../venv2/lib/python2.7/site-packages/zmq/__init__.py", line 44, in <module>
    _libsodium = ctypes.CDLL(bundled_sodium[0], mode=ctypes.RTLD_GLOBAL)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
  OSError: /lib64/libc.so.6: version 'GLIBC_2.14' not found (required by .../venv2/lib/python2.7/site-packages/zmq/libsodium.so)
  linux-vdso.so.1 =>  (0x00007ffc957cf000)
    libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0 (0x00007ffa27a84000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffa27867000)
    libc.so.6 => /lib64/libc.so.6 (0x00007ffa274d2000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007ffa272ce000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007ffa270cb000)
    libm.so.6 => /lib64/libm.so.6 (0x00007ffa26e46000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003f10400000)
  symbol memcpy, version GLIBC_2.14 not defined in file libc.so.6 with link time reference  (.../venv2/lib/python2.7/site-packages/zmq/libsodium.so)

ldd 给出:

(venv2) [host]user: ldd -r -v .../venv2/lib/python2.7/site-packages/zmq/libsodium.so
.../venv2/lib/python2.7/site-packages/zmq/libsodium.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by .../venv2/lib/python2.7/site-packages/zmq/libsodium.so)
    linux-vdso.so.1 =>  (0x00007ffd835e7000)
    libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0 (0x00007f229227b000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f229205e000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f2291cc9000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f2291ac5000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007f22918c2000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f229163d000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003f10400000)
symbol memcpy, version GLIBC_2.14 not defined in file libc.so.6 with link time reference    (.../venv2/lib/python2.7/site-packages/zmq/libsodium.so)

    Version information:
    .../venv2/lib/python2.7/site-packages/zmq/libsodium.so:
        libpthread.so.0 (GLIBC_2.2.5) => /lib64/libpthread.so.0
        libc.so.6 (GLIBC_2.14) => not found
        libc.so.6 (GLIBC_2.3.4) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
    /usr/lib64/libpython2.7.so.1.0:
        libdl.so.2 (GLIBC_2.2.5) => /lib64/libdl.so.2
        libutil.so.1 (GLIBC_2.2.5) => /lib64/libutil.so.1
        libpthread.so.0 (GLIBC_2.2.5) => /lib64/libpthread.so.0
        libm.so.6 (GLIBC_2.2.5) => /lib64/libm.so.6
        libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.3) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.3.4) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
    /lib64/libpthread.so.0:
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_2.2.5) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
        libc.so.6 (GLIBC_2.3.2) => /lib64/libc.so.6
        libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
    /lib64/libc.so.6:
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
    /lib64/libdl.so.2:
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
        libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
    /lib64/libutil.so.1:
        libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
    /lib64/libm.so.6:
        libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6

通过普通桌面登录使用 ipython notebook 时,一切正常,但通过 SSH 使用它总是会出现此错误。通过 SSH 重新安装 venv 没有帮助。我没有 root 访问权限,也没有 sudo。

任何想法如何让它工作?

非常感谢!

4

1 回答 1

1

来自https://docs.python.org/3/library/venv.html

The venv module provides support for creating lightweight “virtual environments”
with their own site directories, optionally isolated from system
site directories.

显然,您的虚拟环境与系统隔离,并且使用的是旧版本的 GLIBC。您问题的 SSH 部分可能是一个红鲱鱼,它venv是导致您的问题的原因,而不是 ssh。

你可以通过运行找到 venv 内外的 glibc 版本/lib64/libc.so.6

一旦您确认libc.so.6内部venv版本早于 2.14……您几乎无法解决此问题。

您可以与维护您的人venv合作以更新其中的 GLIBC 以匹配系统之一,或者您可以尝试创建不需要GLIBC-2.14.

后一种解决方案是不平凡的。两种常见的方法是在chroot环境中编译/链接二进制文件,或者使用 linux-to-older-linux 交叉编译器。

一种更可行的方法可能是始终venv. 然后,他们将在内部和外部工作。

于 2015-10-25T20:47:22.957 回答