gpt4 book ai didi

python - 将 virtualenv 与 Anaconda 一起使用需要更改 LD_LIBRARY_PATH 但会破坏 Emacs

转载 作者:行者123 更新时间:2023-11-28 17:43:40 24 4
gpt4 key购买 nike

我遇到的问题与 this postthis post 中描述的问题类似,但我认为是不同的(或者至少在这些链接文章中的任何答案或评论中都没有回答)。我还发现 this Google groups reply 声明不要将 LD_LIBRARY_PATH 与 Anaconda 一起使用,但我觉得这是不正确的。

  1. 我将 virtualenv 和 virtualenvwrapper 设置为 explained here

  2. 我将 Anaconda 安装到/home/usrname/anaconda

  3. 我试着像这样为 Anaconda 创建一个 virtualenv:

    mkvirtualenv anaconda -p/home/usrname/anaconda/bin/python

但收到以下错误,表明整个 finding-system-python-instead-of-downloaded-2.7.5-python Acaconda 问题:

espears@espears-w:~/anaconda/bin$ mkvirtualenv anaconda -p /home/espears/anaconda/bin/python
Running virtualenv with interpreter /home/espears/anaconda/bin/python
New python executable in anaconda/bin/python
Installing setuptools, pip...
Complete output from command /home/espears/anacon.../anaconda/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/__init__.py", line 3, in <module>
File "/home/espears/anaconda/lib/python2.7/optparse.py", line 77, in <module>
import textwrap
File "/home/espears/anaconda/lib/python2.7/textwrap.py", line 10, in <module>
import string, re
File "/home/espears/anaconda/lib/python2.7/string.py", line 83, in <module>
import re as _re
File "/home/espears/anaconda/bin/anaconda/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/home/espears/anaconda/bin/anaconda/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/home/espears/anaconda/bin/anaconda/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/home/espears/anaconda/bin/anaconda/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2334, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 820, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 988, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 956, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 898, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/espears/anacon.../anaconda/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1

我将 /home/espears/anaconda/lib/ 导出到 LD_LIBRARY_PATH,然后 virtualenv 命令可以正常工作。然后我可以执行 workon anaconda,它正确定位了 Python 的 anaconda 2.7.5 版本,一切都很好。

但后来我尝试启动 Emacs,它似乎(如顶部的链接帖子中所示)不知何故 Anaconda 在 LD_LIBRARY_PATH 中的位置对 Emacs 造成了问题:

espears@espears-w:~$ emacs
Gtk-Message: Failed to load module "canberra-gtk-module"
emacs: symbol lookup error: /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0: undefined symbol: cairo_ft_font_options_substitute

所以问题是:出了什么问题?如果我取消设置 LD_LIBRARY_PATH 的内容,那么 anaconda virtualenv 只会使用系统默认的 Python。但是,如果我单独留下 LD_LIBRARY_PATH,我将无法启动 Emacs。

已添加

这是在将 Anaconda 所需的东西导出到 LD_LIBRARY_PATH 之后 ldd (which emacs) 的输出:

espears@espears-w:~$ export LD_LIBRARY_PATH='/home/espears/anaconda/lib/':$LD_LIBRARY_PATH
espears@espears-w:~$ ldd $(which emacs)
linux-vdso.so.1 => (0x00007fff0a7fe000)
libtiff.so.4 => /usr/lib/x86_64-linux-gnu/libtiff.so.4 (0x00007f504f455000)
libjpeg.so.8 => /home/espears/anaconda/lib/libjpeg.so.8 (0x00007f504f21e000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f504eff5000)
libm.so.6 => /home/espears/anaconda/lib/libm.so.6 (0x00000032b9600000)
libgif.so.4 => /usr/lib/x86_64-linux-gnu/libgif.so.4 (0x00007f504edec000)
libXpm.so.4 => /usr/lib/x86_64-linux-gnu/libXpm.so.4 (0x00007f504ebda000)
libgtk-3.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 (0x00007f504e552000)
libgdk-3.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-3.so.0 (0x00007f504e2d4000)
libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f504df84000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f504dd64000)
libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f504db1b000)
libcairo.so.2 => /home/espears/anaconda/lib/libcairo.so.2 (0x00007f504d841000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f504d5f2000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f504d2fd000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007f504d0f4000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007f504ceda000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f504cba5000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f504c99a000)
libXft.so.2 => /usr/lib/x86_64-linux-gnu/libXft.so.2 (0x00007f504c785000)
libasound.so.2 => /usr/lib/x86_64-linux-gnu/libasound.so.2 (0x00007f504c498000)
librsvg-2.so.2 => /usr/lib/x86_64-linux-gnu/librsvg-2.so.2 (0x00007f504c262000)
libMagickWand.so.4 => /usr/lib/libMagickWand.so.4 (0x00007f504bf4d000)
libMagickCore.so.4 => /usr/lib/libMagickCore.so.4 (0x00007f504baca000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f504b8c1000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f504b67d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f504b460000)
libxml2.so.2 => /home/espears/anaconda/lib/libxml2.so.2 (0x00007f504b114000)
libgpm.so.2 => /usr/lib/x86_64-linux-gnu/libgpm.so.2 (0x00007f504af0e000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f504ace7000)
libgconf-2.so.4 => /usr/lib/x86_64-linux-gnu/libgconf-2.so.4 (0x00007f504aab8000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f504a899000)
libfreetype.so.6 => /home/espears/anaconda/lib/libfreetype.so.6 (0x00007f504a612000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f504a3db000)
libotf.so.0 => /usr/lib/libotf.so.0 (0x00007f504a1c6000)
libm17n-flt.so.0 => /usr/lib/libm17n-flt.so.0 (0x00007f5049fbb000)
libm17n-core.so.0 => /usr/lib/libm17n-core.so.0 (0x00007f5049d8d000)
libgnutls.so.26 => /usr/lib/x86_64-linux-gnu/libgnutls.so.26 (0x00007f5049ad1000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5049711000)
libz.so.1 => /home/espears/anaconda/lib/libz.so.1 (0x00007f50494fb000)
libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f50492f7000)
libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f50490ea000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f5048eda000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f5048cd4000)
libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007f5048ab2000)
libcairo-gobject.so.2 => /usr/lib/x86_64-linux-gnu/libcairo-gobject.so.2 (0x00007f50488a8000)
libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f504867e000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f504846d000)
libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f5048269000)
libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f5048061000)
libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f5047e57000)
libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007f5047c53000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f5047a50000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f5047833000)
libpixman-1.so.0 => /home/espears/anaconda/lib/libpixman-1.so.0 (0x00007f50475b4000)
libpng15.so.15 => /home/espears/anaconda/lib/libpng15.so.15 (0x00007f504737d000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f5047174000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f5046f37000)
libuuid.so.1 => /home/espears/anaconda/lib/libuuid.so.1 (0x00007f5046d33000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f5046b14000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5046910000)
libcroco-0.6.so.3 => /usr/lib/x86_64-linux-gnu/libcroco-0.6.so.3 (0x00007f50466d6000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f50464c7000)
liblcms.so.1 => /usr/lib/x86_64-linux-gnu/liblcms.so.1 (0x00007f5046290000)
liblqr-1.so.0 => /usr/lib/liblqr-1.so.0 (0x00007f504607c000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f5045e6b000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f5045c61000)
/lib64/ld-linux-x86-64.so.2 (0x00007f504f6ce000)
libdbus-glib-1.so.2 => /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2 (0x00007f5045a3a000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f5045810000)
libthai.so.0 => /usr/lib/x86_64-linux-gnu/libthai.so.0 (0x00007f5045606000)
libtasn1.so.3 => /usr/lib/x86_64-linux-gnu/libtasn1.so.3 (0x00007f50453f5000)
libgcrypt.so.11 => /lib/x86_64-linux-gnu/libgcrypt.so.11 (0x00007f5045177000)
libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f5044f64000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f5044d60000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f5044b5a000)
libdatrie.so.1 => /usr/lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007f5044954000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f504474f000)

最佳答案

您可以尝试以下任一建议:

  1. 在启动 emacs 时取消设置 LD_LIBRARY_PATH,例如通过定义别名:alias emacs='LD_LIBRARY_PATH= emacs'(注意空格),或者你可以

  2. export LD_PRELOAD=$(ldd $(which emacs)|grep libpangocairo|awk '{print $3}') 强制使用系统范围的安装 libpangocairo 库。但这可能会破坏 anaconda。

关于python - 将 virtualenv 与 Anaconda 一起使用需要更改 LD_LIBRARY_PATH 但会破坏 Emacs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21029912/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com