Error when using zipline


I am wondering if any body has encountered the same error when using zipline. For example, I wanted to run an algofile using cmd line, but got the following error:

zipline run -f ~/1_files/ml4t/zipline/examples/ --start 2016-1-1 --end 2018-1-1 -o buyapple_out.pickle --no-benchmark

Traceback (most recent call last):
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/exchange_calendars/utils/”, line 47, in get
return self._cache[instance]
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/”, line 383, in getitem
KeyError: <weakref at 0x7f8642862bd0; to ‘BcolzMinuteBarReader’ at 0x7f8642848790>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Users/Chen/miniconda3/envs/ml4t/bin/zipline”, line 11, in
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/click/”, line 1130, in call
return self.main(*args, **kwargs)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/click/”, line 1055, in main
rv = self.invoke(ctx)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/click/”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/click/”, line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/click/”, line 760, in invoke
return __callback(*args, **kwargs)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/zipline/”, line 106, in _
return f(*args, **kwargs)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/click/”, line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/zipline/”, line 300, in run
return _run(
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/zipline/utils/”, line 163, in _run
data = DataPortal(
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/zipline/data/”, line 183, in init
last_minutes = [
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/zipline/data/”, line 184, in
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/exchange_calendars/utils/”, line 49, in get
self._cache[instance] = val = self._get(instance)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/zipline/data/”, line 953, in last_available_dt
_, close = self.calendar.open_and_close_for_session(self._end_session)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/exchange_calendars/”, line 1080, in open_and_close_for_session
session_label = parse_session(self, session_label, “session_label”)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/exchange_calendars/”, line 273, in parse_session
ts = parse_date(session, param_name)
File “/Users/Chen/miniconda3/envs/ml4t/lib/python3.8/site-packages/exchange_calendars/”, line 217, in parse_date
if not ( is None or == “UTC”):
AttributeError: ‘datetime.timezone’ object has no attribute ‘zone’

Does anyone have any idea how to solve this? Thanks a lot!

getting the same error… were you able to resolve this?

Nope. Will let you know when figure this out.

Just FYI. I solved the problem by upgrading zipline-reloaded to the newest version.

Thanks! I updated to 3.0.3 and running on Python 3.10… now getting a different error

AttributeError: ‘datetime.timezone’ object has no attribute ‘key’

You probably can avoid that error by making start and end time unaware, ie, not using .tz_localize("UTC").

1 Like