使用Anaconda在OSX上安装GalSim时遇到问题

使用Anaconda在OSX上安装GalSim时遇到问题,anaconda,galsim,Anaconda,Galsim,我一直试图在OSX 10.9 Mavericks上安装GalSim,安装了Anaconda并将其设置为默认python,但遇到以下错误: Unable to build a python loadable module using the python executable: /usr/bin/env python, the library name libpython2.7.a, and the libdir //anaconda/lib/python2.7/config. If these

我一直试图在OSX 10.9 Mavericks上安装GalSim,安装了Anaconda并将其设置为默认python,但遇到以下错误:

Unable to build a python loadable module using the python executable:
/usr/bin/env python,
the library name libpython2.7.a,
and the libdir //anaconda/lib/python2.7/config.
If these are not the correct library names, you can tell scons the 
correct names to use with the flags EXTRA_LIB_PATH and/or EXTRA_LIBS.
在检查我的config.log文件时,架构x86_64:中有一些未定义符号的实例,尽管我确保使用的编译器是GalSim常见问题解答中推荐的
clang++

以下情况也不计其数:

/usr/bin/env python < .sconf_temp/conftest_73 > .sconf_temp/conftest_73.out
Fatal Python error: PyThreadState_Get: no current thread
sh: line 1: 17019 Abort trap: 6           /usr/bin/env python < ".sconf_temp/conftest_73" > ".sconf_temp/conftest_73.out"
如GalSim常见问题解答中所建议。除了尝试重新安装所有必需的软件包之外,我真的不知道还能尝试什么。在我万不得已之前,有人对我该做什么有什么建议吗?感谢您的帮助

以下是我上次运行SCON的输出:

scons: Reading SConscript files ...
SCons is version 2.3.1 using python version 2.7.6
Python is from //anaconda/include/python2.7
Using the following (non-default) scons options:
   CXX = clang++
These can be edited directly in the file gs_scons.conf.
Type scons -h for a full list of available options.
Using python =  /usr/bin/env python
Using default PYPREFIX =  //anaconda/lib/python2.7/site-packages
Using compiler: /usr/bin/clang++
compiler version: 5.1
Determined that a good number of jobs = 2
Checking for C++ header file fftw3.h... yes
Checking for correct FFTW linkage... yes
Checking for boost header files... yes
Checking for C++ header file TMV.h... yes
Using TMV_LINK file: /usr/local/share/tmv/tmv-link
     -ltmv -lblas
Mac version is 10.9.3
XCode version is 5.1.1
Checking for correct TMV linkage... (this may take a little while)
Checking for correct TMV linkage... yes
Checking if we can build against Python... 
Unable to build a python loadable module using the python executable:
/usr/bin/env python,
the library name libpython2.7.a,
and the libdir //anaconda/lib/python2.7/config.
If these are not the correct library names, you can tell scons the 
correct names to use with the flags EXTRA_LIB_PATH and/or EXTRA_LIBS.

Please fix the above error(s) and rerun scons.
Note: you may want to look through the file INSTALL.md for advice.
Also, if you are having trouble, please check the INSTALL FAQ at 
   https://github.com/GalSim-developers/GalSim/wiki/Installation%20FAQ

迈克尔-我认为你的问题可能与这个问题有关:

简言之,boost似乎有时会声称是针对anaconda python的链接,但尽管如此,它确实是针对系统python的链接


该页面也有一个解决方案。这似乎有点笨拙,所以你可能想看看是否有其他人有想法。但是如果没有,那么您可以尝试一下?

我认为问题的关键在于anaconda的python库没有正确设置安装名称。以下是我的系统上该库的otool报告:

$ otool -L /anaconda/lib/libpython2.7.dylib 
/anaconda/lib/libpython2.7.dylib:
    libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 476.0.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
在Mac上(与其他Unix/Linux变体不同),运行时加载程序查看要加载到动态库或可执行文件中的所有库的安装名称。由于anaconda在这里没有正确的设置,当GalSim或boost针对它编译时,该库只有文件名,没有目录。因此,加载程序不知道它在哪里,在正常位置查找,然后首先找到系统版本

用户2932864给出的答案基本上改变了运行时搜索顺序,将anaconda位置放在系统python之前,因此加载程序会找到anaconda版本。但是,如果您想在系统上同时使用这两个python选项,那么这个解决方案就不能很好地工作。更好的解决方案(IMO)是修复anaconda库文件。为此,只需键入(假设您的anaconda安装在/anaconda中):

在完成这项工作之后,我成功地安装了boost(1.53)

但是boost也有同样的问题。他们也没有正确设置libboost_python.dylib的安装名称。如果这是系统上唯一的boost安装,那么您可能还可以。但是因为我有很多不同的版本,所以我不得不这样做

install_name_tool -id $HOME/anaconda_install/lib/libboost_python.dylib $HOME/anaconda_install/lib/libboost_python.dylib
然后,我能够使用anaconda python以正常方式安装GalSim:

scons PYTHON=/anaconda/bin/python PREFIX=$HOME/anaconda_install BOOST_DIR=$HOME/anaconda_install
sudo scons install

是的,我相信这与我们正在改进的底层RPATH/@dynlib@logic有关:。Linux支持目前已经实现,OS X和Windows在待办事项列表中。

我已经没有耐心了,所以我运行了建议的脚本,目前正在运行GalSim SCON。问题似乎已经解决;GalSim现在能够针对Python进行构建。我将在它完成后运行反转脚本,希望这将是它的结束。
./bootstrap.sh --prefix=$HOME/anaconda_install/ --with-python=/anaconda/bin/python2.7
./b2 link=shared 
./b2 link=shared install
install_name_tool -id $HOME/anaconda_install/lib/libboost_python.dylib $HOME/anaconda_install/lib/libboost_python.dylib
scons PYTHON=/anaconda/bin/python PREFIX=$HOME/anaconda_install BOOST_DIR=$HOME/anaconda_install
sudo scons install