zipline import fails in notebook

444 views
Skip to first unread message

enxo rizzo

unread,
Jan 30, 2017, 10:14:12 AM1/30/17
to Zipline Python Opensource Backtester
Hello,

i'm just starting with zipline, so probably a noob blunder, but i could not find past issues with same symptoms.

In a jupyter notebook, zipline is not found.


environment:
debian kernel 3.16, 64bits, fresh install in a VM
latest anaconda installed
created env with python version 3.4(the default env with 3.5 is not compatible with zipline)

with CLI:
>>>import zipline

works ok

in a notebook:

In [1]: import zipline
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-caeca508216f> in <module>()
----> 1 import zipline

ImportError: No module named 'zipline'

the kernel in the notebook shows the "zipline" env as the default.
i also suffer from this:
https://github.com/quantopian/zipline/issues/1658

from the zipline documentation, there are no extra steps, so i'm lost here. any ideas?

fva...@quantopian.com

unread,
Feb 2, 2017, 2:25:42 PM2/2/17
to Zipline Python Opensource Backtester
Hey Enxo,

Could you test this with another library as well? Something new that's not already part of the default anaconda distribution.

Also, are you sure you're running your IPython kernel inside of your virtualenv? I'm not aware of the notebook showing the default env; usually it just says if you're running Python 2 or Python 3. Could you post a screenshot of this?

enxo rizzo

unread,
Feb 21, 2017, 7:04:32 AM2/21/17
to Zipline Python Opensource Backtester
It seems the replies were direct emails, so, posting here:
Hei fvargus,

sorry for late response, weekend and all..   :)

so, as for env, what i can see is, from the CLI:
(zipline) ➜  notebooks conda info --envs     
# conda environments:
#
zipline               *  /home/deimosaffair/anaconda3/envs/zipline
root                     /home/deimosaffair/anaconda3

(zipline) ➜  notebooks jupyter notebook --port 5005 --ip 0.0.0.0 --no-browser &
[1] 63592

there's and env just for conda with python 3.4, and it's activated. looks good, i lauch jupyter right away. then, in the browser, i get this:
Inline images 1

it appears the jupyter env agrees with the CLI env. also, the list of packages looks ok, and zipline is there:

Quantopian::alembic
0.7.7
py34_0
bcolz
0.12.1
np110py34_0
bottleneck
1.0.0
np110py34_1
Quantopian::cachetools
1.1.6
py34_0

( ...snipped packages here, the formatting makes it  too ugly to bear ...)

wheel
0.29.0
py34_0
xz
5.2.2
1
Quantopian::zipline
1.0.2
np110py34_0
zlib
1.2.8
3


i tried a couple of library installs, but couldn't get them to finish:
1 - they pulled so much dependent stuff, i aborted to avoid the clutter
2 - conda could not find them
3 - pip needed some lib/package, more 200MB to pip a 2
MB lib? no,no,no....

so, any recommendation for that library test?

enxo rizzo

unread,
Feb 21, 2017, 7:07:23 AM2/21/17
to Zipline Python Opensource Backtester
Fargus response:

As far as recommendations for the library test, you should just try installing any library that's not part of the default conda packages. You can always uninstall the library by running pip uninstall library_name, but it's just to test that you're not just having this problem with zipline. 


I've just freshly installed anaconda, and ran conda create -n zip34 python=3.4 anaconda to create a new conda environment for python3.4, and ran conda install zipline and was able to find the package totally normally even after running source activate zip34 and then running import zipline.

enxo rizzo

unread,
Feb 21, 2017, 7:20:59 AM2/21/17
to Zipline Python Opensource Backtester
From what you write, it appears you want me to test that on the CLI, right?

well, it works :)

but it was working already. the problem is (always was) in a jupyter notebook. the documentation/examples in the zipline github repo don't show(or even hint) at any extra steps/configs. It's a 3 step process: 1-copy code, 2-run cell, 3- result good!!

so, either:
1 - the documentation needs an update (it fails to refer that the conda install needs a python3.4 env, so ... )
2 - there's some simple simple setting that should be changed (ENV, jupyter kernel?), and noobs don't know about it :)   

fva...@quantopian.com

unread,
Mar 17, 2017, 10:40:33 AM3/17/17
to Zipline Python Opensource Backtester
Hey Enxo,

Sorry for the delay on my response. Hmm...I'm currently not able to reproduce this. The only thing I'm thinking is that when you're in the conda env, and you're using IPython, it's searching for zipline outside your conda env; in that case it would mean you're running IPython from outside your conda env.

Have you tried creating a new conda env, then installing zipline via the docs on zipline.io? (it sounds like you have but if you could try this again that'd be great).

Also there's a newer version of zipline that we recently released (1.1.0)

On Monday, January 30, 2017 at 10:14:12 AM UTC-5, enxo rizzo wrote:
Reply all
Reply to author
Forward
0 new messages