PyMC3 installation issue

I have followed the installation for macOS page but still could not load properly. I read a lot of similar posts and have uninstalled/installed many times. Any help is much appreciated :slight_smile:

Machine: M1 MacBook Air
OS: macOS 11.2.3
Python: 3.8 via Conda, all related packages up to date with PyMC3 3.10 requirements

Issues:
when importing theano:

You can find the C code in this temporary file: /var/folders/_c/frfzc_f54tbgbycvmnlj9v_w0000gn/T/theano_compilation_error_j2azim5s
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/lazylinker_c.py in <module>
     75         if version != actual_version:
---> 76             raise ImportError(
     77                 "Version check of the existing lazylinker compiled file."

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)
~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/lazylinker_c.py in <module>
     98             if version != actual_version:
---> 99                 raise ImportError(
    100                     "Version check of the existing lazylinker compiled file."

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)
~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/vm.py in <module>
    696         )
--> 697     from . import lazylinker_c
    698 

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

~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2555             # difficult to read.
-> 2556             raise Exception(
   2557                 "Compilation failed (return status=%s): %s"

Exception: Compilation failed (return status=1): In file included from /Users/hgu/.theano/compiledir_macOS-10.16-x86_64-i386-64bit-i386-3.8.5-64/lazylinker_ext/mod.cpp:1:. In file included from /Users/hgu/opt/anaconda3/include/python3.8/Python.h:25:. /Users/hgu/opt/anaconda3/bin/../include/c++/v1/stdio.h:107: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-e2d3ee711e72> in <module>
----> 1 import theano

~/opt/anaconda3/lib/python3.8/site-packages/theano/__init__.py in <module>
     76 __api_version__ = 1
     77 
---> 78 from theano import scalar, tensor
     79 from theano.compile import (
     80     In,

~/opt/anaconda3/lib/python3.8/site-packages/theano/scalar/__init__.py in <module>
----> 1 from .basic import *
      2 from .basic_scipy import *

~/opt/anaconda3/lib/python3.8/site-packages/theano/scalar/basic.py in <module>
     22 
     23 import theano
---> 24 from theano import config, gof, printing
     25 from theano.gof import Apply, Constant, FunctionGraph, Op, Type, Variable, utils
     26 from theano.gradient import DisconnectedType, grad_undefined

~/opt/anaconda3/lib/python3.8/site-packages/theano/printing.py in <module>
     17 import theano
     18 from theano import config, gof
---> 19 from theano.compile import Function, SharedVariable, debugmode
     20 from theano.gof import Apply, Op
     21 

~/opt/anaconda3/lib/python3.8/site-packages/theano/compile/__init__.py in <module>
----> 1 from theano.compile.debugmode import DebugMode
      2 from theano.compile.function.pfunc import Param, pfunc, rebuild_collect_shared
      3 from theano.compile.function.types import (
      4     AliasedMemoryError,
      5     Function,

~/opt/anaconda3/lib/python3.8/site-packages/theano/compile/debugmode.py in <module>
     25     std_fgraph,
     26 )
---> 27 from theano.compile.mode import Mode, register_mode
     28 from theano.compile.ops import OutputGuard, _output_guard
     29 from theano.gof import graph, link, ops_with_inner_function, utils

~/opt/anaconda3/lib/python3.8/site-packages/theano/compile/mode.py in <module>
      8 
      9 import theano
---> 10 import theano.gof.vm
     11 from theano import config, gof
     12 from theano.compile.function.types import Supervisor

~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/vm.py in <module>
    705 except ImportError:
    706     pass
--> 707 except (OSError, theano.gof.cmodule.MissingGXX) as e:
    708     # OSError happens when g++ is not installed.  In that case, we
    709     # already changed the default linker to something else then CVM.

AttributeError: partially initialized module 'theano' has no attribute 'gof' (most likely due to a circular import)

when importing Pymc3

You can find the C code in this temporary file: /var/folders/_c/frfzc_f54tbgbycvmnlj9v_w0000gn/T/theano_compilation_error_nlrt8_5r
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/lazylinker_c.py in <module>
     75         if version != actual_version:
---> 76             raise ImportError(
     77                 "Version check of the existing lazylinker compiled file."

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)
~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/lazylinker_c.py in <module>
     98             if version != actual_version:
---> 99                 raise ImportError(
    100                     "Version check of the existing lazylinker compiled file."

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)
<ipython-input-1-0668865beb19> in <module>
      1 import numpy as np
----> 2 import pymc3 as pm
      3 from scipy.interpolate import griddata, interp2d
      4 import theano.tensor as tt
      5 from matplotlib import pyplot as plt

~/opt/anaconda3/lib/python3.8/site-packages/pymc3/__init__.py in <module>
     37 
     38 
---> 39 __set_compiler_flags()
     40 
     41 from . import gp, ode, sampling

~/opt/anaconda3/lib/python3.8/site-packages/pymc3/__init__.py in __set_compiler_flags()
     31 def __set_compiler_flags():
     32     # Workarounds for Theano compiler problems on various platforms
---> 33     import theano
     34 
     35     current = theano.config.gcc.cxxflags

~/opt/anaconda3/lib/python3.8/site-packages/theano/__init__.py in <module>
     76 __api_version__ = 1
     77 
---> 78 from theano import scalar, tensor
     79 from theano.compile import (
     80     In,

~/opt/anaconda3/lib/python3.8/site-packages/theano/scalar/__init__.py in <module>
----> 1 from .basic import *
      2 from .basic_scipy import *

~/opt/anaconda3/lib/python3.8/site-packages/theano/scalar/basic.py in <module>
     22 
     23 import theano
---> 24 from theano import config, gof, printing
     25 from theano.gof import Apply, Constant, FunctionGraph, Op, Type, Variable, utils
     26 from theano.gradient import DisconnectedType, grad_undefined

~/opt/anaconda3/lib/python3.8/site-packages/theano/printing.py in <module>
     17 import theano
     18 from theano import config, gof
---> 19 from theano.compile import Function, SharedVariable, debugmode
     20 from theano.gof import Apply, Op
     21 

~/opt/anaconda3/lib/python3.8/site-packages/theano/compile/__init__.py in <module>
----> 1 from theano.compile.debugmode import DebugMode
      2 from theano.compile.function.pfunc import Param, pfunc, rebuild_collect_shared
      3 from theano.compile.function.types import (
      4     AliasedMemoryError,
      5     Function,

~/opt/anaconda3/lib/python3.8/site-packages/theano/compile/debugmode.py in <module>
     25     std_fgraph,
     26 )
---> 27 from theano.compile.mode import Mode, register_mode
     28 from theano.compile.ops import OutputGuard, _output_guard
     29 from theano.gof import graph, link, ops_with_inner_function, utils

~/opt/anaconda3/lib/python3.8/site-packages/theano/compile/mode.py in <module>
      8 
      9 import theano
---> 10 import theano.gof.vm
     11 from theano import config, gof
     12 from theano.compile.function.types import Supervisor

~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/vm.py in <module>
    695             "lazylinker will not be imported if theano.config.cxx is not set."
    696         )
--> 697     from . import lazylinker_c
    698 
    699     class CVM(lazylinker_c.CLazyLinker, VM):

~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/lazylinker_c.py in <module>
    137 
    138             args = cmodule.GCC_compiler.compile_args()
--> 139             cmodule.GCC_compiler.compile_str(dirname, code, location=loc, preargs=args)
    140             # Save version into the __init__.py file.
    141             init_py = os.path.join(loc, "__init__.py")

~/opt/anaconda3/lib/python3.8/site-packages/theano/gof/cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2554             # prints the exception, having '\n' in the text makes it more
   2555             # difficult to read.
-> 2556             raise Exception(
   2557                 "Compilation failed (return status=%s): %s"
   2558                 % (status, compile_stderr.replace("\n", ". "))

Exception: Compilation failed (return status=1): In file included from /Users/hgu/.theano/compiledir_macOS-10.16-x86_64-i386-64bit-i386-3.8.5-64/lazylinker_ext/mod.cpp:1:. In file included from /Users/hgu/opt/anaconda3/include/python3.8/Python.h:25:. /Users/hgu/opt/anaconda3/bin/../include/c++/v1/stdio.h:107:15: fatal error: 'stdio.h' file not found. #include_next <stdio.h>.               ^~~~~~~~~. 1 error generated..

Hi, I had a similar set of error messages when trying to install PyMC3.

From my perspective, the problem was installing the packages with conda - for whatever reason I couldn’t get a working set of dependencies.

I ended up re-installing conda (just to ensure I removed any issues with previous versions on packages). Then, with a clean conda installation I installed PyMC with pip. Worked fine after that.

1 Like