Help with issues starting pymc3 (problems with theano?)

WARNING (theano.configdefaults): Only clang++ is supported. With g++, we end up with strange g++/OSX bugs.
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
Traceback (most recent call last):

  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/gof/lazylinker_c.py", line 81, in <module>
You can find the C code in this temporary file: /var/folders/6p/s1lmbd2d1yv0tsqz41x6j9t00000gn/T/theano_compilation_error_q4izdyxt
actual_version, force_compile, _need_reload))
ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/gof/lazylinker_c.py", line 105, in <module>
actual_version, force_compile, _need_reload))
ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/abhishek/Library/Preferences/PyCharmCE2019.1/scratches/scratch.py", line 3, in <module>
import pymc3 as pm
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/pymc3/__init__.py", line 5, in <module>
from .distributions import *
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/pymc3/distributions/__init__.py", line 1, in <module>
from . import timeseries
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/pymc3/distributions/timeseries.py", line 1, in <module>
import theano.tensor as tt
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/__init__.py", line 110, in <module>
from theano.compile import (
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/compile/__init__.py", line 12, in <module>
from theano.compile.mode import *
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/compile/mode.py", line 11, in <module>
import theano.gof.vm
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/gof/vm.py", line 674, in <module>
from . import lazylinker_c
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/gof/lazylinker_c.py", line 140, in <module>
preargs=args)
  File "/Users/abhishek/PycharmProjects/Neutron_Spectrum_Unfold/venv/lib/python3.7/site-packages/theano/gof/cmodule.py", line 2396, in compile_str
(status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): In file included from /usr/local/lib/gcc/x86_64-apple-darwin15.6.0/7.1.0/include-fixed/syslimits.h:7:0,.                  from /usr/local/lib/gcc/x86_64-apple-darwin15.6.0/7.1.0/include-fixed/limits.h:34,.                  from /Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:11,.                  from /Users/abhishek/.theano/compiledir_Darwin-18.6.0-x86_64-i386-64bit-i386-3.7.0-64/lazylinker_ext/mod.cpp:1:. /usr/local/lib/gcc/x86_64-apple-darwin15.6.0/7.1.0/include-fixed/limits.h:194:15: fatal error: limits.h: No such file or directory.  #include_next <limits.h>  /* recurse down to the real one */.                ^~~~~~~~~~. compilation terminated.. 

I’m on MacOS Mojave. This is the code I’m trying to run.

import numpy as np
import pymc3 as pm
import matplotlib.pyplot as plt

obs_y = np.random.normal(0.5,0.35,2000)

with pm.Model() as exercise1:

    stdev = pm.HalfNormal('stdev', sd=.05)
    mu = pm.Normal('mu', mu=0.0, sd = .05)

    y = pm.Normal('y', mu = mu, sd = stdev, observed =obs_y)

    trace = pm.sample(1000)

    pm.traceplot(trace, ['mu','stdev'])
    plt.show()

What’s wrong exactly here? Is there anything I’ve to install? Also how can I change theano config files? Thank you for your time!

Abhishek Cherath

Hey, your code runs fine on my machine, so it is probably a package version / installation issue. This is what I have in my environment:

theano 1.0.4
numpy 1.16.4
pymc3 3.7
python 3.7.3

I did some digging, I think the issue is specific to OSX Mojave (I am still running High Sierra). Check https://github.com/openai/mujoco-py/issues/331. There are a few solutions offered there.

Thank you!

The issue is fixed, the problem was that I didn’t have command line tools installed. so I did xcode-select --install in terminal and now it works.

2 Likes