stan-dev / pystan2

PyStan, the Python interface to Stan
GNU General Public License v3.0
920 stars 189 forks source link

Compilation failed during app development #716

Closed yzheng27 closed 3 years ago

yzheng27 commented 4 years ago

Description:

Hi, I have conda environment dash_eda set up on my machine and it works perfectly in jupyter notebook for the stan model compilation and sampling. And I want to build a Dash app using the same environment dash_eda, but it produces error in the app for the model compilation stage. Any suggestions?

Current Output:

distutils.errors.LinkError: command 'g++' failed with exit status 1

Traceback (most recent call last)
File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/unixccompiler.py", line 205, in link
self.spawn(linker + ld_args)
File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/ccompiler.py", line 910, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
During handling of the above exception, another exception occurred:
File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/unixccompiler.py", line 207, in link
raise LinkError(msg)
distutils.errors.LinkError: command 'g++' failed with exit status 1
Traceback (most recent call last):
  File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/unixccompiler.py", line 205, in link
    self.spawn(linker + ld_args)
  File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/ccompiler.py", line 910, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'g++' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/opt/anaconda3/envs/dash_eda/lib/python3.7/distutils/unixccompiler.py", line 207, in link
    raise LinkError(msg)
distutils.errors.LinkError: command 'g++' failed with exit status 1

PyStan Version: 2.19.0.0

Python Version: 3.7.7

Operating System: MacOS Catalina

(dash_eda) user@x86_64-apple-darwin13 ~ % python --version
Python 3.7.7

(dash_eda) user@x86_64-apple-darwin13 ~ % gcc --version
gcc (MacPorts gcc5 5.5.0_4) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(dash_eda) user@x86_64-apple-darwin13 ~ % g++ --version
g++ (MacPorts gcc5 5.5.0_4) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ahartikainen commented 4 years ago

Do you see C++ error (add verbose=True)

yzheng27 commented 4 years ago

Below are the message generated by adding verbose = True. Not sure if it's C++ error. Thanks.

g++ -bundle -undefined dynamic_lookup -L/Users/user/opt/anaconda3/envs/dash_eda/lib -arch x86_64 -L/Users/user/opt/anaconda3/envs/dash_eda/lib -arch x86_64 -arch x86_64 /var/folders/tq/z6zpr9n51qxbbjq9qj0_bf1m0000gn/T/tmppl7e6de_/var/folders/tq/z6zpr9n51qxbbjq9qj0_bf1m0000gn/T/tmppl7e6de_/stanfit4anon_model_b7776e688e4eb215dda08f3d13c0fe74_2714606035816061165.o -o /var/folders/tq/z6zpr9n51qxbbjq9qj0_bf1m0000gn/T/tmppl7e6de_/stanfit4anon_model_b7776e688e4eb215dda08f3d13c0fe74_2714606035816061165.cpython-37m-darwin.so
ld: unexpected token: !tapi-tbd-v3 file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
ahartikainen commented 4 years ago

How does dash work? Is it running in isolated environment or "normally" with python backend?

Can you try with precompiled model (pickle in python <--> unpickle un app) and try sampling.

yzheng27 commented 4 years ago

Un-pickle precompiled model does work in app, and has no problem in sampling. i built the app in python, but it's also flexible in R and Julia.