stefan-jansen / zipline-reloaded

Zipline, a Pythonic Algorithmic Trading Library
https://zipline.ml4trading.io
Apache License 2.0
1.12k stars 208 forks source link

ModuleNotFoundError: No module named 'zipline' #87

Closed RiccaDS closed 1 year ago

RiccaDS commented 2 years ago

Dear Zipline Maintainers,

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

Environment

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

After launching Jupyter Notebook and using this command %load_ext zipline as suggested in the tutorial at https://zipline.ml4trading.io/beginner-tutorial.html , I am rewarded with the following error ModuleNotFoundError: No module named 'zipline' Also, if I return to the CLI and type any of the following commands $ zipline bundles, $ zipline ingest -b quandl I get instruction not allowed (core dump created)

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

Reproduction Steps

  1. delete all environments (be in base)
  2. $ sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
  3. $ bash Anaconda3-2021.11-Linux-x86_64.sh
  4. $ conda create -n env_zipline python=3.8
  5. $ conda activate env_zipline
  6. $ conda install -c ml4t -c conda-forge -c ranaroussi zipline-reloaded
  7. $ jupyter notebook
  8. in a new sheet launch the command %load_ext zipline

What steps have you taken to resolve this already?

-I have tried different versions of python -I have tried to restrain Pandas version to a maximum allowed version I don't actually remember but it was indicated as a possible solution on a post. -I installed anaconda-navigator and installed jupyter notebook(JN) from within it, then launched JN both from the CLI and from Anaconda-navigator. At this point the new error on import of the module in JN-Python 3 (ipykernel) is The kernel appears to have died. It will restart automatically. -I tried doing the same steps on the base environment and with different combinations to no avail.

It is to be noted that before installing anaconda I have default Python 3.8.10 64bit packages installed. I am fairly new to linux and python so dunno if that matters.

Sincerely, Riccardo

stefan-jansen commented 2 years ago

One thing that jumps out is that the hipline-reloaded version you have is a bit older - we are currently at 2.2. To have conda load the most recent versions, you may have to run

conda update conda

first.

Second, if the interpreter doesn't find the installed module, this suggest it is looking on the wrong path (e.g. your previous Python installation). One way to find out what's actually running is to execute

import sys
sys.prefix

in the notebook as this will show you which interpreter is running. If this is not your environment's interpreter, then either something went wrong while activating the environment (restart the shell and retry) or, more fundamentally, with the conda setup (it adds some code to your shell config files to ensure it's on the path). Here is one way to validate the installation.

Hope this helps, please let me know if it doesn't!

RiccaDS commented 2 years ago

Thank you for the indications @stefan-jansen , I am getting nuts over this. Will test this in the evening and report back.

RiccaDS commented 2 years ago

@stefan-jansen ok I wasn't able to make it work using conda. Honestly I made so many tests that I don't remember exactly all what went wrong, but conda gives some problems. In the end I was able to make it work with pip install. For those who need it these are the commands I used, these are also what can be found on the installation instructions: $ conda env create -n zipenv $ conda activate zipenv $ sudo apt install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev hdf5-tools $ wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz $ tar -xzf ta-lib-0.4.0-src.tar.gz $ cd ta-lib/ $ sudo ./configure $ sudo make $ sudo make install $ cd .. $ pip install zipline-reloaded For testing purposes run $ zipline run --help

To ingest Quandl bundle get your key and add the corresponding environment variable called QUANDL_API_KEY $ conda install matplotlib $ jupyter notebook etc..

As I have some time I will retry with conda on another environment and report back the problems. Thank you

iceman273 commented 2 years ago

Thanks @RiccaDS. I had the same problem. conda install from the ml4t channel did not work, but the pip install solved the issue.

stefan-jansen commented 1 year ago

We have just updated Zipline to 2.4 (currently in beta) and should have the new version up on conda-forge in a week or so pending a new exchange-calendar release.