简体   繁体   中英

Can not import Zipline with Anaconda

So I am trying to import zipline with anaconda. Though due to the fact that zipline requires python 3.5 I created an environment with python 3.5 in it. I did conda install zipline in the environment's terminal and it says it has successfully installed, then when I open python within the environment, and I import zipline no errors come up. I also have jupyter notebook installed in the env, when I import zipline in ipython, it causes no errors. But then when I open Jupiter notebook through the environment, then open a new kernel and try to import zipline, it says the module does not exist (I have even imported numpy and other things that are also downloaded and they work fine in the same jupyter notebook tab, and I also I am opening JN through the 3.5 env terminal not the base terminal). Please help, thank you.

EDIT: An example of the code could be

import numpy as np 
np.sqrt(16)

This will return:

4.0

Then if I import zipline:

!conda install -c quantopian zipline
import zipline as zp
import numpy as np
np.sqrt(16)

There is no output, it just skips to the next cell without an error popping up, and also the I[1] part of the cell changes to I[*] instead of I[2] (I am new at python so probably I am doing something wrong)

what I get from pip show zipline in the terminal

Name: zipline
Version: 1.3.0
Summary: A backtester for financial algorithms.
Home-page: http://zipline.io
Author: Quantopian Inc.
Author-email: opensource@quantopian.com
License: Apache 2.0
Location: c:\users\benito\anaconda3\envs\env_zipline\lib\site-packages
Requires: pip, setuptools, Logbook, pytz, numpy, requests-file, scipy, pandas, pandas-datareader, patsy, statsmodels, python-dateutil, six, requests, Cython, cyordereddict, bottleneck, contextlib2, decorator, networkx, numexpr, bcolz, click, toolz, multipledispatch, MarkupSafe, Mako, sqlalchemy, alembic, sortedcontainers, intervaltree, lru-dict, empyrical, tables, trading-calendars

The first thing is it is required to install jupyter notebook for every environment. So at first make sure that you have installed jupyter notebook correctly on the required environment. If you have installed it correctly then open jupyter notebook and in a code cell write any one of the following commands and execute the cell.

!conda install -c quantopian zipline -y

or

!conda install -c quantopian/label/ci zipline -y

After this execution import the library again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM