Zipline library importation not working

I have gone through the Zipline sample strategy and understand all the code. I then went to edit the code to implement my own strategy. However, upon the first step of importing the necessary packages, I receive an error. Here is how to recreate the issue and the error I am getting:

  1. Open a new research notebook in Python

  2. type the following into an empty cell:

import zipline.api as algo
from zipline.pipeline import Pipeline
from zipline.pipeline.factors import AverageDollarVolume, Returns
from zipline.finance.execution import MarketOrder

  1. Hit shift + enter to run the cell

The error received is the following:


ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import zipline.api as algo
2 from zipline.pipeline import Pipeline
3 from zipline.pipeline.factors import AverageDollarVolume, Returns
4 from zipline.finance.execution import MarketOrder

ModuleNotFoundError: No module named 'zipline'

NOTE: I have also tried running "from quantrocket import zipline" before the code above. "from quantrocket import zipline" works, however I still then receive an error when importing those other packages.

Hmm, it sounds like the Zipline APIs are missing. Are you using the Zipline environment or the ordinary Python environment?

You can change the kernel with the Kernel menu, Change Kernel, Zipline environment.

HTH! dpc

@dominic.cooney, I tried doing that, and the only option for the Kernels is "Python 3". Am I missing something? Thank you!

When you run quantrocket version what does it say? Mine is 2.1.1. The Zipline environment is new since 2.1.0.

2 Likes

@dominic.cooney is correct, you need to update to the latest version.

1 Like