GVKun编程网logo

使用LD_LIBRARY_PATH时与Anaconda链接的问题(ld_library_path 不起作用)

20

本文将分享使用LD_LIBRARY_PATH时与Anaconda链接的问题的详细内容,并且还将对ld_library_path不起作用进行详尽解释,此外,我们还将为大家带来关于AndroidNDK–未

本文将分享使用LD_LIBRARY_PATH时与Anaconda链接的问题的详细内容,并且还将对ld_library_path 不起作用进行详尽解释,此外,我们还将为大家带来关于Android NDK – 未找到库无法链接EXECUTABLE – 如何设置LD_LIBRARY_PATH?、android – LD_LIBRARY_PATH定义必需的libs、c – LD_LIBRARY_PATH、Conda仅将env设置为LD_LIBRARY_PATH的相关知识,希望对你有所帮助。

本文目录一览:

使用LD_LIBRARY_PATH时与Anaconda链接的问题(ld_library_path 不起作用)

使用LD_LIBRARY_PATH时与Anaconda链接的问题(ld_library_path 不起作用)

我只是尝试在Linux 64位上安装Anaconda。一切似乎都运行良好,但是当我尝试从终端启动IPython时,出现以下错误:

$ ipythonTraceback (most recent call last):  File "/home/josh/installs/conda/1.7.0/bin/ipython", line 4, in <module>    from IPython import start_ipython  File "/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/IPython/__init__.py", line 43, in <module>    from .config.loader import Config  File "/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/IPython/config/__init__.py", line 16, in <module>    from .application import *  File "/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/IPython/config/application.py", line 27, in <module>    from collections import defaultdict  File "/home/josh/installs/conda/1.7.0/lib/python2.7/collections.py", line 9, in <module>    from operator import itemgetter as _itemgetter, eq as _eqImportError: /home/josh/installs/conda/1.7.0/lib/python2.7/lib-dynload/operator.so: undefined symbol: _PyUnicodeUCS4_AsDefaultEncodedString

如果尝试更新conda,则会收到相同的错误:

$ conda update conda                                                                                                      Traceback (most recent call last):  File "/home/josh/installs/conda/1.7.0/bin/conda", line 3, in <module>    from conda.cli import main  File "/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/conda/cli/__init__.py", line 8, in <module>    from conda.cli.main import main  File "/home/josh/installs/conda/1.7.0/lib/python2.7/site-packages/conda/cli/main.py", line 43, in <module>    import argparse  File "/home/josh/installs/conda/1.7.0/lib/python2.7/argparse.py", line 85, in <module>    import collections as _collections  File "/home/josh/installs/conda/1.7.0/lib/python2.7/collections.py", line 9, in <module>    from operator import itemgetter as _itemgetter, eq as _eqImportError: /home/josh/installs/conda/1.7.0/lib/python2.7/lib-dynload/operator.so: undefined symbol: _PyUnicodeUCS4_AsDefaultEncodedString

这也很奇怪,因为它看起来像安装了Python 2.7.4,而不是Python 2.7.5。我刚刚下载了它(10月1日)。

$ pythonPython 2.7.4 (default, Apr 21 2013, 18:37:10)[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2Type "help", "copyright", "credits" or "license" for more information.

并且我的计算机上有以下内容.bashrcPATH=/home/josh/installs/conda/1.7.0/bin:$PATH
这似乎正在完成工作: $ which python /home/josh/installs/conda/1.7.0/bin/python
我在此处安装了可用的版本。以下是完整的安装日志:

[/home/josh/installs/conda] >>> /home/josh/installs/conda/1.7.0/PREFIX=/home/josh/conda/1.7.0installing: python-2.7.5-2 ...installing: conda-1.9.1-py27_0 ...installing: _license-1.1-py27_0 ...installing: apptools-4.2.0-py27_0 ...installing: astropy-0.2.4-np17py27_1 ...installing: atom-0.3.2-py27_0 ...installing: binstar-0.3.1-py27_0 ...installing: biopython-1.61-np17py27_0 ...installing: bitarray-0.8.1-py27_0 ...installing: bokeh-0.1.1-np17py27_0 ...installing: boto-2.12.0-py27_0 ...installing: cairo-1.12.2-1 ...installing: casuarius-1.1-py27_0 ...installing: chaco-4.3.0-np17py27_1 ...installing: configobj-4.7.2-py27_0 ...installing: cubes-0.10.2-py27_3 ...installing: curl-7.30.0-0 ...installing: cython-0.19.1-py27_0 ...installing: dateutil-2.1-py27_2 ...installing: disco-0.4.4-py27_0 ...installing: distribute-0.6.45-py27_0 ...installing: docutils-0.11-py27_0 ...installing: dynd-python-0.4.2-np17py27_0 ...installing: enable-4.3.0-np17py27_0 ...installing: enaml-0.7.19-py27_1 ...installing: envisage-4.3.0-py27_0 ...installing: erlang-R15B01-0 ...installing: flask-0.10.1-py27_1 ...installing: freetype-2.4.10-0 ...installing: gevent-0.13.8-py27_0 ...installing: gevent-websocket-0.3.6-py27_2 ...installing: gevent_zeromq-0.2.5-py27_2 ...installing: greenlet-0.4.1-py27_0 ...installing: grin-1.2.1-py27_1 ...installing: h5py-2.2.0-np17py27_0 ...installing: hdf5-1.8.9-0 ...installing: imaging-1.1.7-py27_3 ...installing: ipython-1.0.0-py27_0 ...installing: ipython-notebook-1.0.0-py27_0 ...installing: ipython-qtconsole-1.0.0-py27_0 ...installing: itsdangerous-0.23-py27_0 ...installing: jinja2-2.7.1-py27_0 ...installing: jpeg-8d-0 ...installing: keyring-3.0.1-py27_0 ...installing: launcher-0.1.2-py27_0 ...installing: libdynd-0.4.2-0 ...installing: libevent-2.0.20-0 ...installing: libnetcdf-4.2.1.1-1 ...installing: libpng-1.5.13-1 ...installing: libtiff-4.0.2-0 ...installing: libxml2-2.9.0-0 ...installing: libxslt-1.1.28-0 ...installing: llvm-3.3-0 ...installing: llvmmath-0.1.1-np17py27_2 ...installing: llvmpy-0.12.0-py27_0 ...installing: lxml-3.2.3-py27_0 ...installing: markupsafe-0.18-py27_0 ...installing: matplotlib-1.3.0-np17py27_0 ...installing: mayavi-4.3.0-np17py27_1 ...installing: mdp-3.3-np17py27_0 ...installing: meta-0.4.2.dev-py27_0 ...installing: mpi4py-1.3-py27_0 ...installing: mpich2-1.4.1p1-0 ...installing: netcdf4-1.0.5-np17py27_0 ...installing: networkx-1.8.1-py27_0 ...installing: nltk-2.0.4-np17py27_0 ...installing: nose-1.3.0-py27_0 ...installing: numba-0.10.2-np17py27_0 ...installing: numexpr-2.0.1-np17py27_3 ...installing: numpy-1.7.1-py27_0 ...installing: opencv-2.4.6-np17py27_0 ...installing: openssl-1.0.1c-0 ...installing: pandas-0.12.0-np17py27_0 ...installing: patsy-0.2.1-np17py27_0 ...installing: pep8-1.4.6-py27_0 ...installing: pip-1.4.1-py27_0 ...installing: pixman-0.26.2-0 ...installing: ply-3.4-py27_0 ...installing: psutil-1.0.1-py27_0 ...installing: py-1.4.14-py27_0 ...installing: py2cairo-1.10.0-py27_1 ...installing: pycosat-0.6.0-py27_0 ...installing: pycparser-2.9.1-py27_0 ...installing: pycrypto-2.6-py27_0 ...installing: pycurl-7.19.0-py27_2 ...installing: pyface-4.3.0-py27_0 ...installing: pyflakes-0.7.3-py27_0 ...installing: pygments-1.6-py27_0 ...installing: pyparsing-1.5.6-py27_0 ...installing: pysal-1.6.0-np17py27_1 ...installing: pysam-0.6-py27_0 ...installing: pyside-1.2.1-py27_0 ...installing: pytables-2.4.0-np17py27_0 ...installing: pytest-2.3.5-py27_0 ...installing: pytz-2013b-py27_0 ...installing: pyyaml-3.10-py27_0 ...installing: pyzmq-2.2.0.1-py27_1 ...installing: qt-4.8.5-0 ...installing: readline-6.2-0 ...installing: redis-2.6.9-0 ...installing: redis-py-2.7.2-py27_0 ...installing: requests-1.2.3-py27_0 ...installing: rope-0.9.4-py27_0 ...installing: scikit-image-0.8.2-np17py27_2 ...installing: scikit-learn-0.14.1-np17py27_0 ...installing: scipy-0.12.0-np17py27_0 ...installing: shiboken-1.2.1-py27_0 ...installing: six-1.4.1-py27_0 ...installing: sphinx-1.1.3-py27_4 ...installing: spyder-2.2.4-py27_0 ...installing: spyder-app-2.2.4-py27_0 ...installing: sqlalchemy-0.8.2-py27_0 ...installing: sqlite-3.7.13-0 ...installing: statsmodels-0.5.0-np17py27_0 ...installing: sympy-0.7.3-py27_0 ...installing: system-5.8-1 ...installing: theano-0.5.0-np17py27_1 ...installing: tk-8.5.13-0 ...installing: tornado-3.1.1-py27_0 ...installing: traits-4.3.0-py27_0 ...installing: traitsui-4.3.0-py27_0 ...installing: util-linux-2.21-0 ...installing: vtk-5.10.1-py27_0 ...installing: werkzeug-0.9.4-py27_0 ...installing: xlrd-0.9.2-py27_0 ...installing: xlwt-0.7.5-py27_0 ...installing: yaml-0.1.4-0 ...installing: zeromq-2.2.0-1 ...installing: zlib-1.2.7-0 ...installing: anaconda-1.7.0-np17py27_0 ...installing: _cache-0.0-x0 ...Python 2.7.5 :: Continuum Analytics, Inc.creating default environment...installation finished.Do you wish the installer to prepend the Anaconda install locationto PATH in your /home/josh/.bashrc ? [yes|no][no] >>> yesPrepending PATH=/home/josh/installs/conda/1.7.0/bin to PATH in /home/josh/.bashrcA backup will be made to: /home/josh/.bashrc-anaconda.bakFor this change to become active, you have to open a new terminal.Thank you for installing Anaconda!

答案1

小编典典

在您的系统上,Anaconda正在获取libpython的“系统版本”,它是使用2字节Unicode编译的,而Anaconda是使用4字节Unicode编译的。由于某种原因,这是一种不寻常的情况,指示的operator.so文件的动态加载程序正在使用您的系统libpython库。

另外,无论您使用什么PATH,看起来都在运行python时获得了标准的“系统” Python。

您是否已启动新终端或运行#source .bashrc?您正在使用哪个Linux发行版?您的环境中是否设置了LD_LIBRARY_PATH?

请注意,还会在https://github.com/ContinuumIO/conda/issues/296上询问此问题,因此可能会有答案。

Android NDK – 未找到库无法链接EXECUTABLE – 如何设置LD_LIBRARY_PATH?

Android NDK – 未找到库无法链接EXECUTABLE – 如何设置LD_LIBRARY_PATH?

我有一个 Android活动,我正在执行NDK编译代码(命令行程序):

Runtime.getRuntime().exec(myCommand);

并使用以下命令加载所需的共享库:

static {
    System.loadLibrary(myLib);
}

但是当运行我的项目并从错误流打印输出时,我收到以下错误:

link_image[1963]:  7520 Could not load needed library ''libmyLib.so'' for ''./myCommand''
(load_library[1105]: Library ''libmyLib.so'' not found)CANNOT LINK EXECUTABLE

我保证libmyLib.so确实存在于libs / armeabi /目录下的项目中,并且它被复制到我的Android设备下的/data/data/myProject.path.package/lib/目录下.可执行文件和库的所有者和组都是系统:系统和权限也是可以的.

在开始时从adb shell执行命令时我得到了相同的错误但是我可以设置LD_LIBRARY_PATH并运行正常:

./adb shell
export LD_LIBRARY_PATH=/data/data/myProject.path.package/lib:$LD_LIBRARY_PATH
/data/data/myProject.path.package/myCommand

所以问题是,如何从java Android项目中做到这一点?

注意:我在GT-P1010上使用Linux,Eclipse Sequoyah,NDK-r5b,Android 2.3.6(API 10).

解决方法

解决:你可以使用exec(String prog,String [] envp).在我的情况下,这是:

String[] envp = {"LD_LIBRARY_PATH=/data/data/cse.ecg.dcmtk/lib:$LD_LIBRARY_PATH"};
Runtime.getRuntime().exec(myCommand,envp);

现在的问题是,使用exec()执行的进程无法解析主机名(它来自adb shell;设置了Internet权限).有什么暗示吗?

android – LD_LIBRARY_PATH定义必需的libs

android – LD_LIBRARY_PATH定义必需的libs

我想确保将任何必需的库添加到开发的 Android应用程序中.因此,我试图将它正确定义到 LD_LIBRARY_PATH.命令ldd用于检查我的Qt应用程序需要哪些库.

当我在Ubuntu上运行ldd时,它应该给我MyApp所需的lib列表.但是,这是我到目前为止所得到的:

$cd MyAppProjFolder
$ldd MyApp | grep libQt
ldd: ./MyApp: not regular file
$file MyApp
MyApp: directory
$cd Debug
$ldd MyApp | grep libQt
./MyApp: No such file or directory
$cd android-build
$ldd MyApp | grep libQt
./MyApp: No such file or directory
$cd bin
$ldd MyApp | grep libQt
./MyApp: No such file or directory

要查找可执行文件的位置,请运行以下命令:

$find /home/user/MyAppProjFolder -name MyApp
/MyAppProjFolder/.../bin/classes/org/qtproject/example/MyApp
$ldd MyApp | grep libQt
./MyApp: No such file or directory

我在这里错过了什么?生成的可执行文件与定义的项目/应用程序的名称不同?

解决方法

根据评论中的对话,您似乎有以下错误:

1)您正在尝试在目录或不存在的文件上运行ldd.

2)您似乎在目标二进制文件上从主机运行ldd.它不一定相同.

我的建议是找到你的可执行文件,并确保你运行正确的ldd.

编辑:因为您在初始帖子之后将问题的要点修改到一定程度,所以回复:

What am I missing here?

如何在同一个文件中使用find和ldd.

The executable file generated is different from the name of the defined project/app?

它是您/您在构建系统中定义的内容,因此我们无法知道,特别是如果您不粘贴相关代码.

c – LD_LIBRARY_PATH

c – LD_LIBRARY_PATH

我可以为单个应用程序设置LD_LIBRARY_PATH吗?
 我正在调查系统调用失败,所以有什么方法可以设置使用LD_LIBRARY_PATH设置设置正确的路径?

解决方法

最简单的方法是创建一个 shell脚本.

让shell脚本导出新的LD_LIBRARY_PATH变量,然后启动您的应用程序

例如(foo是你的应用)

#!/bin/sh
LD_LIBRARY_PATH=some_path:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
foo

Conda仅将env设置为LD_LIBRARY_PATH

Conda仅将env设置为LD_LIBRARY_PATH

我安装了miniconda3,并在其中创建了一个名为py35的虚拟环境。我有一些我只想在此环境中使用的库。因此他们在

 /.../miniconda3/envs/py35/libs

但是,由于LD_LIBRARY_PATH不包含上述文件夹,因此无法从环境中找到它们。现在,我想将LD_LIBRARY_PATH设置为仅在虚拟环境中时才包含/
lib。

我当时正在考虑修改miniconda用来启动环境的激活脚本,但是不确定这是标准做法还是有更简单的方法来实现。

答案1

小编典典

您可以在环境激活时通过编辑activate.d/env_vars.sh脚本来设置环境变量。参见此处:https : //conda.io/docs/user-
guide/tasks/manage-environments.html#macos-and-
linux

该链接的关键部分是:

  1. 在“终端”窗口中找到conda环境的目录,例如/home/jsmith/anaconda3/envs/analytics

  2. 输入该目录并创建以下子目录和文件:

    cd /home/jsmith/anaconda3/envs/analytics

    mkdir -p ./etc/conda/activate.d
    mkdir -p ./etc/conda/deactivate.d
    touch ./etc/conda/activate.d/env_vars.sh
    touch ./etc/conda/deactivate.d/env_vars.sh

  3. 编辑./etc/conda/activate.d/env_vars.sh如下:

    #!/bin/sh

    export MY_KEY=’secret-key-value’
    export MY_FILE=/path/to/my/file/

  4. 编辑./etc/conda/deactivate.d/env_vars.sh如下:

    #!/bin/sh

    unset MY_KEY
    unset MY_FILE

运行时conda activate analytics,环境变量MY_KEY和MY_FILE设置为您写入文件中的值。运行时condadeactivate,这些变量将被擦除。

今天关于使用LD_LIBRARY_PATH时与Anaconda链接的问题ld_library_path 不起作用的讲解已经结束,谢谢您的阅读,如果想了解更多关于Android NDK – 未找到库无法链接EXECUTABLE – 如何设置LD_LIBRARY_PATH?、android – LD_LIBRARY_PATH定义必需的libs、c – LD_LIBRARY_PATH、Conda仅将env设置为LD_LIBRARY_PATH的相关知识,请在本站搜索。

本文标签: