Problems with Pymc3 after updating to MacOS Mojave


#1

I recently updated to MacOS Mojave. Now, when I try to import pymc3, I get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/anaconda3/lib/python3.6/site-packages/theano/gof/lazylinker_c.py in <module>()
     80                     version,
---> 81                     actual_version, force_compile, _need_reload))
     82 except ImportError:

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:

ImportError                               Traceback (most recent call last)
/anaconda3/lib/python3.6/site-packages/theano/gof/lazylinker_c.py in <module>()
    104                         version,
--> 105                         actual_version, force_compile, _need_reload))
    106         except ImportError:

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:

Exception                                 Traceback (most recent call last)
/anaconda3/lib/python3.6/site-packages/theano/gof/vm.py in <module>()
    673         raise theano.gof.cmodule.MissingGXX('lazylinker will not be imported if theano.config.cxx is not set.')
--> 674     from . import lazylinker_c
    675 

/anaconda3/lib/python3.6/site-packages/theano/gof/lazylinker_c.py in <module>()
    139             cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 140                                              preargs=args)
    141             # Save version into the __init__.py file.

/anaconda3/lib/python3.6/site-packages/theano/gof/cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2390             raise Exception('Compilation failed (return status=%s): %s' %
-> 2391                             (status, compile_stderr.replace('\n', '. ')))
   2392         elif config.cmodule.compilation_warning and compile_stderr:

Exception: Compilation failed (return status=1): In file included from /Users/demetri/.theano/compiledir_Darwin-18.0.0-x86_64-i386-64bit-i386-3.6.6-64/lazylinker_ext/mod.cpp:1:. In file included from /anaconda3/include/python3.6m/Python.h:25:. /anaconda3/bin/../include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found. #include_next <stdio.h>.               ^~~~~~~~~. 1 error generated.. 

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-4-2e5c536b7c65> in <module>()
----> 1 import pymc3 as pm

/anaconda3/lib/python3.6/site-packages/pymc3/__init__.py in <module>()
      3 
      4 from .blocking import *
----> 5 from .distributions import *
      6 from .external import *
      7 from .glm import *

/anaconda3/lib/python3.6/site-packages/pymc3/distributions/__init__.py in <module>()
----> 1 from . import timeseries
      2 from . import transforms
      3 
      4 from .continuous import Uniform
      5 from .continuous import Flat

/anaconda3/lib/python3.6/site-packages/pymc3/distributions/timeseries.py in <module>()
----> 1 import theano.tensor as tt
      2 from theano import scan
      3 
      4 from pymc3.util import get_variable_name
      5 from .continuous import get_tau_sd, Normal, Flat

/anaconda3/lib/python3.6/site-packages/theano/__init__.py in <module>()
    108     object2, utils)
    109 
--> 110 from theano.compile import (
    111     SymbolicInput, In,
    112     SymbolicOutput, Out,

/anaconda3/lib/python3.6/site-packages/theano/compile/__init__.py in <module>()
     10 from theano.compile.function_module import *
     11 
---> 12 from theano.compile.mode import *
     13 
     14 from theano.compile.io import *

/anaconda3/lib/python3.6/site-packages/theano/compile/mode.py in <module>()
      9 import theano
     10 from theano import gof
---> 11 import theano.gof.vm
     12 from theano import config
     13 from six import string_types

/anaconda3/lib/python3.6/site-packages/theano/gof/vm.py in <module>()
    681 except ImportError:
    682     pass
--> 683 except (OSError, theano.gof.cmodule.MissingGXX) as e:
    684     # OSError happens when g++ is not installed.  In that case, we
    685     # already changed the default linker to something else then CVM.

AttributeError: module 'theano' has no attribute 'gof'

Looks like it might be a problem with theano. Anyone else experiencing this?


Suggested fixes for pymc3 and Mojave not working
#2

Did you update your Xcode? Try opening Xcode and accept the new licence agreement (if there is any).


#3

Downloaded the newest edition of Xcode. Same error.


#4

I wonder if this could be related: https://github.com/Theano/Theano/issues/6645 which also has a suggestion for a fix (https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html#macos-sdk).


#5

EDIT: This has allowed pymc3 to be imported, but now models will not sample.

Thanks, this seems to have solved the problem.

For posterity, users experiencing the same problem should download the repository found here: https://github.com/devernay/xcodelegacy and run the command ./XcodeLegacy.sh install


#6

#7

I ran into this as well, and had some more luck following this stack overflow post.

The tl;dr is that XCode is not placing key header files in /usr/include and instead bundling them with the MacOS SDK. They provide a program that will move them there for you /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg.

You can read about it a bit more in their release notes.

Hope this helps someone else!