"tz-aware UTC" issue when trying to run example files

I am getting the same error for both the dma.py and buy_apple.py example files:

(base) C:\Users\tsfer>zipline run -f buyapple.py --start 2016-1-1 --end 2018-1-1 -o buyapple_out.pickle --no-benchmark
[2021-10-25 13:17:22.070951] INFO: zipline.finance.metrics.tracker: Simulated 503 trading days
first open: 2016-01-04 14:31:00+00:00
last close: 2017-12-29 21:00:00+00:00
Traceback (most recent call last):
File “C:\Users\tsfer\anaconda3\Scripts\zipline-script.py”, line 10, in
File “C:\Users\tsfer\anaconda3\lib\site-packages\click\core.py”, line 764, in call
return self.main(*args, **kwargs)
File “C:\Users\tsfer\anaconda3\lib\site-packages\click\core.py”, line 717, in main
rv = self.invoke(ctx)
File “C:\Users\tsfer\anaconda3\lib\site-packages\click\core.py”, line 1137, in invoke
return process_result(sub_ctx.command.invoke(sub_ctx))
File “C:\Users\tsfer\anaconda3\lib\site-packages\click\core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “C:\Users\tsfer\anaconda3\lib\site-packages\click\core.py”, line 555, in invoke
return callback(*args, **kwargs)
File "C:\Users\tsfer\anaconda3\lib\site-packages\zipline_main
.py", line 106, in _
return f(*args, **kwargs)
File “C:\Users\tsfer\anaconda3\lib\site-packages\click\decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “C:\Users\tsfer\anaconda3\lib\site-packages\zipline_main_.py”, line 322, in run
File “C:\Users\tsfer\anaconda3\lib\site-packages\zipline\utils\run_algo.py”, line 221, in _run
“script”: algotext,
File “C:\Users\tsfer\anaconda3\lib\site-packages\zipline\algorithm.py”, line 641, in run
daily_stats = self._create_daily_stats(perfs)
File “C:\Users\tsfer\anaconda3\lib\site-packages\zipline\algorithm.py”, line 665, in _create_daily_stats
daily_dts = pd.DatetimeIndex([p[“period_close”] for p in daily_perfs], tz=“UTC”)
File “C:\Users\tsfer\anaconda3\lib\site-packages\pandas\core\indexes\datetimes.py”, line 253, in new
File “C:\Users\tsfer\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py”, line 320, in _from_sequence
File “C:\Users\tsfer\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py”, line 1755, in sequence_to_dt64ns
tz = maybe_infer_tz(tz, inferred_tz)
File “C:\Users\tsfer\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py”, line 1968, in maybe_infer_tz
f"data is already tz-aware {inferred_tz}, unable to "
TypeError: data is already tz-aware UTC, unable to set specified tz: UTC

no pickle file is saved as a result…any thoughts?

I had no issue running the examples with zipline-reloaded 2.1.1 pandas 1.2.5 ( on Debian/Linux though). Check your versions. FYI there is a pickle bug in 2.1.1 due to a missing underscore. It is fixed but not yet released in a version https://github.com/stefan-jansen/zipline-reloaded/pull/56

thanks for the reply, but it now looks to be a time zone-related issue…

I tried running buy_apple.py using the IDE method, and it simply threw:

TypeError: data is already tz-aware UTC, unable to set specified tz: UTC

I tried removing the “tz_localize(‘UTC’)” on both start and end variables without success
start = pd.Timestamp(‘2014’)
end = pd.Timestamp(‘2018’)

result = run_algorithm(start=start.tz_localize('UTC'),

The only thing that I could think of right now, is that something is wrong with the data that you ingested (try to pull it again maybe).
I have no experience and cannot help you unfortunately if something is wrong with a conda installation.

based on previous user issues, I thought my issue might be because of a newer version of pandas, but I just checked and I am running:


if you do have pandas 1.0.1 that’s indeed going to be an issue. It should be >= 1.1.0 <1.2.5.

thanks @MBounouar !! I upgraded pandas to 1.2.4 and it is working now…

actually I forgot an = sign you can upgrade to 1.2.5 if you want

ha k thx, might try that at some point