Fails to import in GCP's Datalab

138 views
Skip to first unread message

rich...@rezco.co.za

unread,
Jun 29, 2017, 2:06:13 AM6/29/17
to Zipline Python Opensource Backtester

Hi There.


I'm trying to use Zipline on GCP's Datalab.


I've successfully installed Zipline using:
! apt-get update
! apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev -y
! pip install zipline

When I now try to run
import zipline
I get:
ImportErrorTraceback (most recent call last)
in ()
----> 1 import zipline
/usr/local/lib/python2.7/dist-packages/zipline/init.py in ()
35 # This is not a place to dump arbitrary classes/modules for convenience,
36 # it is a place to expose the public interfaces.
---> 37 from . import data
38 from . import finance
39 from . import gens
ImportError: cannot import name data


Any ideas on how I can overcome this?

Ed Bartosh

unread,
Jun 29, 2017, 9:59:49 AM6/29/17
to rich...@rezco.co.za, Zipline Python Opensource Backtester
Hi Richard,

Does  'import zipline.data' breaks with more verbose output?

Regards,
Ed 


Rezco Collective Investments Ltd is an FSB approved Unit Trust Management Company.  Please click on the following link to read the Rezco legal notice: http://rezco.co.za/email-legal-notice/.  Preserving Capital* & Creating Wealth. *While the portfolio manager will attempt to minimise risk, it is possible that the investor could incur losses, including the loss of principal invested.

--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BR,
Ed

Ed Bartosh

unread,
Jun 29, 2017, 1:05:23 PM6/29/17
to Richardt Benade | REZCO, Zipline Python Opensource Backtester
Unfortunately it does not.
I think it does. Either python or you are much more verbose now :)

My suspicion is that you have incorrect version of empyrical package. You can see correct version in <zipline clone>/etc/requirements.txt
in my clone it's 0.2.2

$ grep empyrical git/zipline/etc/requirements.txt 
empyrical==0.2.2

If you version differs you can install it with pip install empyrical==0.2.2

Regards,
Ed


2017-06-29 18:35 GMT+03:00 Richardt Benade | REZCO <rich...@rezco.co.za>:
Hi Ed

Thanks for your reply. Unfortunately it does not.

However, when I run import zipline the first time, I get

================

ImportErrorTraceback (most recent call last)
<ipython-input-5-caeca508216f> in <module>()
----> 1 import zipline

/usr/local/lib/python2.7/dist-packages/zipline/__init__.py in <module>()
     40 from . import utils
     41 from .utils.calendars import get_calendar
---> 42 from .utils.run_algo import run_algorithm
     43 from ._version import get_versions
     44 

/usr/local/lib/python2.7/dist-packages/zipline/utils/run_algo.py in <module>()
     15 from toolz import valfilter, concatv
     16 
---> 17 from zipline.algorithm import TradingAlgorithm
     18 from zipline.data.bundles.core import load
     19 from zipline.data.data_portal import DataPortal

/usr/local/lib/python2.7/dist-packages/zipline/algorithm.py in <module>()
     83     StopOrder,
     84 )
---> 85 from zipline.finance.performance import PerformanceTracker
     86 from zipline.finance.asset_restrictions import Restrictions
     87 from zipline.finance.slippage import (

/usr/local/lib/python2.7/dist-packages/zipline/finance/performance/__init__.py in <module>()
     14 # limitations under the License.
     15 
---> 16 from . tracker import PerformanceTracker
     17 from . period import PerformancePeriod
     18 from . position import Position

/usr/local/lib/python2.7/dist-packages/zipline/finance/performance/tracker.py in <module>()
     67 from zipline.finance.performance.period import PerformancePeriod
     68 from zipline.errors import NoFurtherDataError
---> 69 import zipline.finance.risk as risk
     70 
     71 from . position_tracker import PositionTracker

/usr/local/lib/python2.7/dist-packages/zipline/finance/risk/__init__.py in <module>()
     14 # limitations under the License.
     15 
---> 16 from . report import RiskReport
     17 from . period import RiskMetricsPeriod
     18 from . cumulative import RiskMetricsCumulative

/usr/local/lib/python2.7/dist-packages/zipline/finance/risk/report.py in <module>()
     62 from dateutil.relativedelta import relativedelta
     63 
---> 64 from . period import RiskMetricsPeriod
     65 
     66 log = logbook.Logger('Risk Report')

/usr/local/lib/python2.7/dist-packages/zipline/finance/risk/period.py in <module>()
     26 from . risk import check_entry
     27 
---> 28 from empyrical import (
     29     alpha_beta_aligned,
     30     annual_volatility,

ImportError: cannot import name information_ratio
=========================



When I run it again afterwards, the error changes to

==============================

ImportErrorTraceback (most recent call last)
in ()
----> 1 import zipline
/usr/local/lib/python2.7/dist-packages/zipline/init.py in ()
35 # This is not a place to dump arbitrary classes/modules for convenience,
36 # it is a place to expose the public interfaces.
---> 37 from . import data
38 from . import finance
39 from . import gens
ImportError: cannot import name data

==============================


Thanks!

Kind regards
Richardt Benade
Analyst
m. +27 72 594 8792|t. +27 861 739 468
s. Unit 33A, Katherine & West Building, 114 West Street, Sandton, 2196, South Africa
rich...@rezco.co.zawww.rezco.co.za



--
BR,
Ed

Richardt Benade | REZCO

unread,
Jun 30, 2017, 3:32:47 AM6/30/17
to Ed Bartosh, Zipline Python Opensource Backtester
Many thanks Ed. 

Maybe a bit of both :-)

I did indeed have another version of empyrical installed. 

After uninstalling empyrical and installing empyrical 0.2.2, Zipline now imports successfully. 

Based on http://www.zipline.io/beginner-tutorial.html I'm now trying to run the default example:

Inline images 1

However, I get the attached error. 

Any suggestions? Sorry for pestering you with this.




Kind regards
Richardt Benade
Analyst
m. +27 72 594 8792|t. +27 861 739 468
s. Unit 33A, Katherine & West Building, 114 West Street, Sandton, 2196, South Africa
rich...@rezco.co.zawww.rezco.co.za

zipline_error.txt

Ed Bartosh

unread,
Jun 30, 2017, 3:57:56 AM6/30/17
to Richardt Benade | REZCO, Zipline Python Opensource Backtester
Hi Richardt,

Looks like you've hit Yahoo benchmark issue: https://github.com/quantopian/zipline/issues/1776

You can use my temporary fixes for it from zipline-live repository:
or wait until the issue is fixed in zipline.


Regards,
Ed

--
BR,
Ed

Richardt Benade | REZCO

unread,
Jun 30, 2017, 3:59:25 AM6/30/17
to Ed Bartosh, Zipline Python Opensource Backtester
Thanks Ed, much appreciated

Kind regards
Richardt Benade
Analyst
m. +27 72 594 8792|t. +27 861 739 468
s. Unit 33A, Katherine & West Building, 114 West Street, Sandton, 2196, South Africa
rich...@rezco.co.zawww.rezco.co.za

Reply all
Reply to author
Forward
0 new messages