quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.27k stars 4.67k forks source link

ImportError: No module named zipline in jupyter notebbok #2660

Open lucaspalomeque opened 4 years ago

lucaspalomeque commented 4 years ago

Dear Zipline Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

packages in environment at /opt/anaconda3/envs/env_zipline:

#

Name Version Build Channel

alembic 0.7.7 py35_0 Quantopian appnope 0.1.0 pypi_0 pypi asn1crypto 0.24.0 py35_0 attrs 19.3.0 pypi_0 pypi backcall 0.1.0 pypi_0 pypi bcolz 0.12.1 np114py35_0 Quantopian blas 1.0 mkl bleach 3.1.1 pypi_0 pypi blosc 1.16.3 hd9629dc_0 bottleneck 1.2.1 py35h1d22016_1 bzip2 1.0.8 h1de35cc_0 ca-certificates 2020.1.1 0 certifi 2018.8.24 py35_1 cffi 1.11.5 py35h6174b99_1 chardet 3.0.4 py35_1 click 7.0 py_0 contextlib2 0.6.0.post1 py_0 cryptography 2.3.1 py35hdbc3d79_0 cycler 0.10.0 pypi_0 pypi cyordereddict 0.2.2 py35_0 Quantopian cython 0.28.5 py35h0a44026_0 dbus 1.13.12 h90a0687_0 decorator 4.4.1 py_0 defusedxml 0.6.0 pypi_0 pypi empyrical 0.5.0 py35_0 Quantopian entrypoints 0.3 pypi_0 pypi expat 2.2.6 h0a44026_0 gettext 0.19.8.1 h15daf44_3 glib 2.63.1 hd977a24_0 hdf5 1.10.2 hfa1e0ec_1 icu 58.2 h4b95b61_1 idna 2.7 py35_0 importlib-metadata 1.5.0 pypi_0 pypi intel-openmp 2019.4 233 intervaltree 2.1.0 py35_0 Quantopian ipykernel 5.1.4 pypi_0 pypi ipython 7.9.0 pypi_0 pypi ipython-genutils 0.2.0 pypi_0 pypi ipython_genutils 0.2.0 py35hf129286_0 ipywidgets 7.5.1 pypi_0 pypi jedi 0.16.0 pypi_0 pypi jinja2 2.11.1 py_0 jpeg 9b he5867d9_2 jsonschema 3.2.0 pypi_0 pypi jupyter 1.0.0 py35_7 jupyter-client 5.3.4 pypi_0 pypi jupyter-console 6.1.0 pypi_0 pypi jupyter-core 4.6.3 pypi_0 pypi jupyter_client 5.3.3 py_0 jupyter_console 5.2.0 py35hd2aa692_1 jupyter_core 4.5.0 py_0 kiwisolver 1.1.0 pypi_0 pypi lab 5.3 pypi_0 pypi libcxx 4.0.1 hcfea43d_1 libcxxabi 4.0.1 hcfea43d_1 libedit 3.1.20181209 hb402a30_0 libffi 3.2.1 h475c297_4 libgfortran 3.0.1 h93005f0_2 libiconv 1.15 hdd342a3_7 libpng 1.6.37 ha441bb4_0 libsodium 1.0.16 h3efe00b_0 libxml2 2.9.9 hf6e021a_1 libxslt 1.1.33 h33a18ac_0 logbook 0.12.5 py35_0 Quantopian lru-dict 1.1.4 py35_0 Quantopian lxml 4.2.5 py35hef8c89e_0 lz4-c 1.8.1.2 h1de35cc_0 lzo 2.10 h362108e_2 mako 1.1.1 py_0 markupsafe 1.0 py35h1de35cc_1 matplotlib 3.0.3 pypi_0 pypi mistune 0.8.4 pypi_0 pypi mkl 2018.0.3 1 multipledispatch 0.6.0 py35_0 nbconvert 5.6.1 pypi_0 pypi nbformat 5.0.4 py_0 ncurses 6.1 h0a44026_1 networkx 1.11 py35_1 notebook 6.0.3 pypi_0 pypi numexpr 2.6.1 np114py35_0 Quantopian numpy 1.14.2 py35ha9ae307_0 openssl 1.0.2u h1de35cc_0 pandas 0.22.0 py35h0a44026_0 pandas-datareader 0.8.1 py_0 pandoc 2.2.3.2 0 pandocfilters 1.4.2 py35_1 parso 0.6.1 pypi_0 pypi patsy 0.5.0 py35_0 pcre 8.43 h0a44026_0 pexpect 4.8.0 pypi_0 pypi pickleshare 0.7.5 pypi_0 pypi pip 10.0.1 py35_0 prometheus_client 0.7.1 py_0 prompt-toolkit 2.0.10 pypi_0 pypi prompt_toolkit 1.0.15 py35h93950c5_0 ptyprocess 0.6.0 pypi_0 pypi pycparser 2.19 py35_0 pygments 2.5.2 py_0 pyopenssl 18.0.0 py35_0 pyparsing 2.4.6 pypi_0 pypi pyqt 5.9.2 py35h655552a_2 pyrsistent 0.15.7 pypi_0 pypi pysocks 1.6.8 py35_0 pytables 3.4.4 py35h13cba08_0 python 3.5.6 hc167b69_0 python-dateutil 2.8.1 py_0 pytz 2019.3 py_0 pyzmq 18.1.1 pypi_0 pypi qt 5.9.7 h468cd18_1 qtconsole 4.6.0 py_1 readline 7.0 h1de35cc_5 requests 2.20.1 py35_0 Quantopian requests-file 1.4.3 py35_0 scipy 1.1.0 py35hcaad992_0 send2trash 1.5.0 pypi_0 pypi setuptools 40.2.0 py35_0 simplegeneric 0.8.1 py35_2 simplejson 3.17.0 pypi_0 pypi sip 4.19.8 py35h0a44026_0 six 1.11.0 py35_1 snappy 1.1.7 he62c110_3 sortedcontainers 2.0.5 py35_0 sqlalchemy 1.2.11 py35h1de35cc_0 sqlite 3.31.1 ha441bb4_0 statsmodels 0.9.0 py35h917ab60_0 terminado 0.8.3 pypi_0 pypi testpath 0.4.4 py_0 tk 8.6.8 ha441bb4_0 toolz 0.10.0 py_0 tornado 6.0.3 pypi_0 pypi trading-calendars 1.11.1 py35_0 Quantopian traitlets 4.3.3 pypi_0 pypi urllib3 1.23 py35_0 wcwidth 0.1.8 py_0 webencodings 0.5.1 pypi_0 pypi wheel 0.31.1 py35_0 widgetsnbextension 3.5.1 pypi_0 pypi xz 5.2.4 h1de35cc_4 zeromq 4.2.5 h0a44026_1 zipline 1.3.0 np114py35_0 Quantopian zipp 1.2.0 pypi_0 pypi zlib 1.2.11 h1de35cc_3 zstd 1.3.7 h5bba6e5_0

* Operating System: (OSmojave 10.14) * Python Version: `Python 3.5.6 :: Anaconda, Inc.` * Python Bitness: `$ python -c 'import math, sys;print(int(math.log(sys.maxsize + 1, 2) + 1))'` * How did you install Zipline: (conda env) * Python packages: `$ pip freeze` or `$ conda list`

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

Here is how you can reproduce this issue on your machine:

Reproduction Steps

Install zipline by creating a new conda environment Run jupyter notebook in cmd %load_ext zipline .

What steps have you taken to resolve this already?

Going through this https://github.com/quantopian/zipline/issues/2190

Anything else?

Try to understand if this was related too : https://github.com/quantopian/zipline/issues/2170 ...

Sincerely, Lucas

shwartin commented 4 years ago

I have the same error, when i'm trying run jupyter notebook outside virtualenv.

Try to do smth like this:

  1. create virtualenv
  2. activate you virtualenv
  3. install zipline inside virtualenv
  4. try to import zipline in virtualenv
  5. check that it works
python
import zipline

if you have no errors, that's ok

  1. run jupyter notebook inside virtualenv
ssanderson commented 4 years ago

@lucaspalomeque This sounds to me like it's more likely a jupyter configuration issue than a zipline specific issue. Are you sure that your jupyter kernel is running in the same environment where you installed zipline? One easy way to check that is to print the result of sys.executable.