0

抱歉,如果这不是问的正确地方,但这似乎是一个一般的安装问题,而不是一个 pystan 问题......

我正在尝试运行一些简单的 pystan 示例,这是一个 Python 贝叶斯推理包,但它始终崩溃。因此,例如,当我在https://pystan.readthedocs.io/en/latest/getting_started.html运行“入门,示例 1”示例时(除了我在给出错误的行中添加了“verbose=True”) , 在线

sm = pystan.StanModel(model_code=schools_code, verbose=True)

我得到一个很长的错误跟踪,开头是:

INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_19a09b474d1901f191444eaf8a6b8ce2 NOW.
INFO:pystan:OS: darwin, Python: 2.7.14 |Anaconda, Inc.| (default, Oct  5 2017, 02:28:52) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)], Cython 0.26.1
Compiling /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_8277449399850120616.pyx because it changed.
[1/1] Cythonizing /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_8277449399850120616.pyx
building 'stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_8277449399850120616' extension
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/var
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/var/folders
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/var/folders/6l
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl
gcc -fno-strict-aliasing -I/Users/peter/miniconda2/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl -I/Users/peter/miniconda2/lib/python2.7/site-packages/pystan -I/Users/peter/miniconda2/lib/python2.7/site-packages/pystan/stan/src -I/Users/peter/miniconda2/lib/python2.7/site-packages/pystan/stan/lib/stan_math -I/Users/peter/miniconda2/lib/python2.7/site-packages/pystan/stan/lib/stan_math/lib/eigen_3.3.3 -I/Users/peter/miniconda2/lib/python2.7/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0 -I/Users/peter/miniconda2/lib/python2.7/site-packages/pystan/stan/lib/stan_math/lib/sundials_4.1.0/include -I/Users/peter/miniconda2/lib/python2.7/site-packages/numpy/core/include -I/Users/peter/miniconda2/include/python2.7 -c /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_8277449399850120616.cpp -o /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpQqJaIl/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_8277449399850120616.o -O2 -ftemplate-depth-256 -Wno-unused-function -Wno-uninitialized -std=c++1y
dyld: Library not loaded: /usr/local/opt/mpfr/lib/libmpfr.4.dylib
  Referenced from: /usr/local/Cellar/gcc/7.2.0/libexec/gcc/x86_64-apple-darwin16.7.0/7.2.0/cc1plus
  Reason: image not found
gcc: internal compiler error: Abort trap: 6 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://github.com/Homebrew/homebrew-core/issues> for instructions.

我在 Mac OS X 10.12.5 上使用 miniconda。无论我运行 python2 还是 python3,我都会收到相同的错误。(上面的trace是python2;Python3是python 3.6.8,7月25日安装)。

关键错误似乎是它希望找到文件 /usr/local/opt/mpfr/lib/libmpfr.4.dylib 。当我查看该目录时,我看到一个文件 libmpfr.6.dylib 和 libmpfr.dylib ,它是 libmpfr.dylib 的符号链接,但没有 libmpfr.4.dylib

我想知道假设的库路径是否发生了一些可怕的事情,比如假设 /usr/bin/python 而不是 ~/miniconda2/bin/python 使用的库(这是我用于 python 的,因为 ~/miniconda2/ bin 位于我的 bash shell PATH 的前面)。

那么...我是否需要安装较旧的(rev 4)版本的 libmpfr ?如果是这样,怎么做?

更新:看到回复(如下)后,我更新了 gcc(到 9.2)和 conda。但现在它在其他地方崩溃了......

INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_19a09b474d1901f191444eaf8a6b8ce2 NOW.
INFO:pystan:OS: darwin, Python: 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)], Cython 0.28.5
Compiling /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416.pyx because it changed.
[1/1] Cythonizing /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416.pyx
building 'stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416' extension
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/var
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/var/folders
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/var/folders/6l
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T
creating /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/peter/miniconda3/include -arch x86_64 -I/Users/peter/miniconda3/include -arch x86_64 -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3 -I/Users/peter/miniconda3/lib/python3.6/site-packages/pystan -I/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/src -I/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math -I/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/eigen_3.3.3 -I/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0 -I/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/sundials_4.1.0/include -I/Users/peter/miniconda3/lib/python3.6/site-packages/numpy/core/include -I/Users/peter/miniconda3/include/python3.6m -c /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416.cpp -o /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416.o -O2 -ftemplate-depth-256 -Wno-unused-function -Wno-uninitialized -std=c++1y
In file included from /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416.cpp:642:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1824:
/Users/peter/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with " \
 ^
In file included from /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416.cpp:646:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan_fit.hpp:12:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/date_time/posix_time/posix_time_types.hpp:10:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/date_time/time_clock.hpp:17:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/shared_ptr.hpp:17:
/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/smart_ptr/shared_ptr.hpp:370:174: error: no member named 'move' in namespace 'std'
    BOOST_CONSTEXPR shared_ptr( boost::detail::sp_internal_constructor_tag, element_type * px_, boost::detail::shared_count && pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( std::move( pn_ ) )
                                                                                                                                                                        ~~~~~^
/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/smart_ptr/shared_ptr.hpp:927:27: error: no member named 'move' in namespace 'std'; did you mean 'modf'?
    return shared_ptr<T>( std::move(r), p );
                          ^~~~~~~~~
                          modf
/usr/include/math.h:407:15: note: 'modf' declared here
extern double modf(double, double *);
              ^
In file included from /var/folders/6l/mw9lfs_51h74dfvg458rrn1c0000gp/T/tmpw103deo3/stanfit4anon_model_19a09b474d1901f191444eaf8a6b8ce2_6187777314581226416.cpp:646:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan_fit.hpp:12:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/date_time/posix_time/posix_time_types.hpp:10:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/date_time/time_clock.hpp:17:
In file included from /Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/shared_ptr.hpp:17:
/Users/peter/miniconda3/lib/python3.6/site-packages/pystan/stan/lib/stan_math/lib/boost_1.69.0/boost/smart_ptr/shared_ptr.hpp:937:27: error: no member named 'move' in namespace 'std'; did you mean 'modf'?
    return shared_ptr<T>( std::move(r), p );

                          modf
/usr/include/math.h:407:15: note: 'modf' declared here
extern double modf(double, double *);
              ^
4

1 回答 1

0

这与python无关。该错误来自安装在您机器上的 GCC /usr/local/Cellar,它预期libmpfr.4.dylib对应于 MPFR 3.x。您需要安装预期的较新 GCC libmpfr.6.dylib(MPFR 4.x),或安装 MPFR 3.x。但请注意,MPFR 3.x 很旧,有未修复的错误,并且不再维护。

于 2019-09-24T13:34:48.503 回答