Error problems in Optimal Growth I (Dynamic Programming)

Hi, some guys including me found it impossible to implement the codes provided in
“Optimal Growth I: The Stochastic Optimal Growth Mode” due to some error.

We use jupyter notebook and the 11th cell does not work.
(The subsequent contents in Optimal Growth I and Optimal Growth II seem to have the same problem.)
Here is the (very long) error message:

TypingError Traceback (most recent call last)
4 v_init = v_star(grid, α, β, μ) # Start at the solution
----> 5 v = T(v_init) # Apply the Bellman operator once
7 fig, ax = plt.subplots(figsize=(9, 5))

~\Anaconda3\lib\site-packages\numba\ in _compile_for_args(self, *args, **kws)
346 e.patch_message(msg)
–> 348 error_rewrite(e, ‘typing’)
349 except errors.UnsupportedError as e:
350 # Something unsupported is present in the user code, add help info

~\Anaconda3\lib\site-packages\numba\ in error_rewrite(e, issue_type)
313 raise e
314 else:
–> 315 reraise(type(e), e, None)
317 argtypes = []

~\Anaconda3\lib\site-packages\numba\ in reraise(tp, value, tb)
656 value = tp()
657 if value.traceback is not tb:
–> 658 raise value.with_traceback(tb)
659 raise value

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Internal error at <numba.typeinfer.CallConstraint object at 0x000001EE0C601EB8>:
Traceback (most recent call last):
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 609, in new_error_context
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 259, in lower_block
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 403, in lower_inst
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 442, in lower_static_raise
self.return_exception(inst.exc_class, inst.exc_args, loc=self.loc)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 164, in return_exception
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\targets\”, line 367, in return_user_exc
fname = loc._raw_function_name()
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 63, in _raw_function_name
return self._defmatcher.match(defn.strip()).groups()[0]
AttributeError: ‘NoneType’ object has no attribute ‘groups’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 141, in propagate
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 422, in call
self.resolve(typeinfer, typevars, fnty)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 446, in resolve
sig = typeinfer.resolve_call(fnty, pos_args, kw_args)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 1231, in resolve_call
return self.context.resolve_function_type(fnty, pos_args, kw_args)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\typing\”, line 190, in resolve_function_type
res = self._resolve_user_function_type(func, args, kws)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\typing\”, line 242, in _resolve_user_function_type
return func.get_call_type(self, args, kws)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\types\”, line 280, in get_call_type
template, pysig, args, kws = self.dispatcher.get_call_template(args, kws)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 272, in get_call_template
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 655, in compile
cres = self._compiler.compile(args, return_type)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 82, in compile
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 926, in compile_extra
return pipeline.compile_extra(func)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 374, in compile_extra
return self._compile_bytecode()
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 857, in _compile_bytecode
return self._compile_core()
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 844, in _compile_core
res =
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 255, in run
raise patched_exception
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 246, in run
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 717, in stage_nopython_backend
self._backend(lowerfn, objectmode=False)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 666, in _backend
lowered = lowerfn()
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 653, in backend_nopython_mode
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 1048, in native_lowering_stage
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 178, in lower
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 219, in lower_normal_function
entry_block_tail = self.lower_function_body()
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 244, in lower_function_body
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 259, in lower_block
File “C:\Users\shcor\Anaconda3\lib\”, line 130, in exit
self.gen.throw(type, value, traceback)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 617, in new_error_context
six.reraise(type(newerr), newerr, tb)
File “C:\Users\shcor\Anaconda3\lib\site-packages\numba\”, line 659, in reraise
raise value
numba.errors.LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
‘NoneType’ object has no attribute ‘groups’

File “…\Anaconda3\lib\site-packages\quantecon\optimize\”, line 50:
… def f(x):

if not np.isfinite(a):
raise ValueError(“a must be finite.”)

[1] During: lowering “raise <class ‘ValueError’>(‘a must be finite.’)” at C:\Users\shcor\Anaconda3\lib\site-packages\quantecon\optimize\ (50)
[2] During: resolving callee type: type(CPUDispatcher(<function brent_max at 0x000001EE0B8D5048>))
[3] During: typing of call at (30)


File “”, line 30:
def T(v):

# Solve for optimal v at y
v_max = brent_max(objective, 1e-10, y, args=(v, y))[1]

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:

For more information about typing errors and how to debug them visit:

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:

Thanks a lot in advance!

Hi @cryptopia, thanks for reporting.

There were some issues with a previous version of Anaconda (and Numba in particular).

Would you mind to install the latest version of Anaconda (personally, I just delete my existing one and install the latest version) and update the quantecon library (pip install --upgrade quantecon)?

After that I hope this problem will disappear. If not please let us know.

Regards, John.

Thank you so much for your very quick and useful comment!

I re-installed the newest version of Anaconda and the problem has completely disappeared.
(I tested on Jupyter Notebook and Visual Studio Code, both of which successfully worked as desired.)

I should have tried re-installing before asking (I’m sorry), but thanks anyway!

Thanks good news @cryptopia. All feedback is welcome so please let us know if you have more issues or suggestions.

Good luck with your studies. John.