Prophet: Installation failed with Ubuntu 16, python 2.7 and conda

Created on 4 Mar 2017  路  9Comments  路  Source: facebook/prophet

Hi guys,

I'm trying to install prophet in a dedicated conda virtualenv in Ubuntu 16 with Python 2.7. As far as you can see below I cannot manage to proper build wheels for the package. The first ImportError seems related to pystan:

ImportError: /tmp/tmpZK6GOa/stanfit4anon_model_35bf14a7f93814266f16b4cf48b40a5a_5074582750541262742.so: undefined symbol: _ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE

but I'm not figuring out how to solve it.

Here are my pip freeze for the relevant dependencies (installed via conda):

pandas==0.19.2
pystan==2.14.0.0
python-dateutil==2.6.0
pytz==2016.10
numpy==1.11.3
six==1.10.0

Do you have any hint?

Traceback:

$ pip install fbprophet
Collecting fbprophet
  Using cached fbprophet-0.1.post1.tar.gz
Requirement already satisfied: pandas in /my_env/lib/python2.7/site-packages (from fbprophet)
Requirement already satisfied: pystan in /my_env/lib/python2.7/site-packages (from fbprophet)
Requirement already satisfied: python-dateutil in /my_env/lib/python2.7/site-packages (from pandas->fbprophet)
Requirement already satisfied: pytz>=2011k in /my_env/lib/python2.7/site-packages (from pandas->fbprophet)
Requirement already satisfied: numpy>=1.7.0 in /my_env/lib/python2.7/site-packages (from pandas->fbprophet)
Requirement already satisfied: six>=1.5 in /my_env/lib/python2.7/site-packages (from python-dateutil->pandas->fbprophet)
Building wheels for collected packages: fbprophet
  Running setup.py bdist_wheel for fbprophet ... error
  Complete output from command /my_env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7eSp8U/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpOoUUxSpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/fbprophet
  creating build/lib/fbprophet/stan_models
  INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_35bf14a7f93814266f16b4cf48b40a5a NOW.
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-7eSp8U/fbprophet/setup.py", line 96, in <module>
      """
    File "/my_env/lib/python2.7/distutils/core.py", line 151, in setup
      dist.run_commands()
    File "/my_env/lib/python2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/my_env/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/my_env/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 179, in run
      self.run_command('build')
    File "/my_env/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/my_env/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/my_env/lib/python2.7/distutils/command/build.py", line 127, in run
      self.run_command(cmd_name)
    File "/my_env/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/my_env/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-7eSp8U/fbprophet/setup.py", line 20, in run
      self.build_stan_models()
    File "/tmp/pip-build-7eSp8U/fbprophet/setup.py", line 32, in build_stan_models
      sm = StanModel(model_code=model_code)
    File "/my_env/lib/python2.7/site-packages/pystan/model.py", line 315, in __init__
      self.module = load_module(self.module_name, lib_dir)
    File "/my_env/lib/python2.7/site-packages/pystan/model.py", line 54, in load_module
      return imp.load_module(module_name, *module_info)
  ImportError: /tmp/tmpUHb0k9/stanfit4anon_model_35bf14a7f93814266f16b4cf48b40a5a_5074564914923231717.so: undefined symbol: _ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE

  ----------------------------------------
  Failed building wheel for fbprophet
  Running setup.py clean for fbprophet
Failed to build fbprophet
Installing collected packages: fbprophet
  Running setup.py install for fbprophet ... error
    Complete output from command /my_env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7eSp8U/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-QS7ss5-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/fbprophet
    creating build/lib/fbprophet/stan_models
    INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_35bf14a7f93814266f16b4cf48b40a5a NOW.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-7eSp8U/fbprophet/setup.py", line 96, in <module>
        """
      File "/my_env/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/my_env/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/my_env/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/my_env/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg/setuptools/command/install.py", line 61, in run
      File "/my_env/lib/python2.7/distutils/command/install.py", line 563, in run
        self.run_command('build')
      File "/my_env/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/my_env/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/my_env/lib/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/my_env/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/my_env/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-7eSp8U/fbprophet/setup.py", line 20, in run
        self.build_stan_models()
      File "/tmp/pip-build-7eSp8U/fbprophet/setup.py", line 32, in build_stan_models
        sm = StanModel(model_code=model_code)
      File "/my_env/lib/python2.7/site-packages/pystan/model.py", line 315, in __init__
        self.module = load_module(self.module_name, lib_dir)
      File "/my_env/lib/python2.7/site-packages/pystan/model.py", line 54, in load_module
        return imp.load_module(module_name, *module_info)
    ImportError: /tmp/tmpZK6GOa/stanfit4anon_model_35bf14a7f93814266f16b4cf48b40a5a_5074582750541262742.so: undefined symbol: _ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE

    ----------------------------------------
Command "/my_env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7eSp8U/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-QS7ss5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-7eSp8U/fbprophet/

Most helpful comment

conda install gcc?

All 9 comments

Forgot to mention that I tried the test depicted here (https://github.com/facebookincubator/prophet/issues/48 and https://github.com/facebookincubator/prophet/issues/64):

import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)
y = model.sampling(n_jobs=1).extract()['y']
y.mean()  # with luck the result will be near 0

The test fails with the same reasons:

ImportError: /tmp/tmpyaa14N/stanfit4anon_model_5944b02c79788fa0db5b3a93728ca2bf_7653202503018146861.so: undefined symbol: _ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE

So as suggested by @mcnemesis I checked the memory, but in my case this machine has 8GB RAM and the process can easily access more than 6GB free RAM.

I can replicate this error on Ubuntu 16.04 using Python 3.6 with 8 GB free memory.
ImportError: /tmp/tmpccwjco29/stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_3399486209992570694.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE

Edit: in a new environment the install was successful so it seems there's some issues with pystan and other packages

It seems that issue is related with a mismatch between the gcc version used to compile anconda and the system gcc (the anaconda one is older and not completely compatible with newer). See https://github.com/stan-dev/pystan/issues/292 and https://github.com/stan-dev/pystan/issues/269 for more details and maybe also these are relevant: https://github.com/ContinuumIO/anaconda-issues/issues/1465 and https://github.com/ContinuumIO/anaconda-issues/issues/577

As far as I can see the only way is a downgrade of gcc.

Is there any other option?

conda install gcc?

@mingwandroid thank you very much! Your solution works like a charm!

update gcc-5;g++-5;gcc-5-multilib;g++-5mulitilib
python3.5
then it work

Thanks @mingwandroid!

The solution works like a charm!

wow, thanks @mingwandroid

Was this page helpful?
0 / 5 - 0 ratings