问题
I am not able to import the zipline.transforms module
>>> from zipline.transforms import batch_transform
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'zipline.transforms'
回答1:
Disclaimer: I'm currently a maintainer of Zipline.
I'm guessing the reason you're seeing this error is because that particular module was removed a while back (assuming you're using zipline 1.0.0 or later). If you want to do things similar to transforms
you'll need to call data.history()
to get your pricing data, and call numpy/pandas functions like .avg()
or .std()
, or use talib
.
回答2:
I think you should firstly print out your sys.path
(print sys.path
), and then see where you zipline module is installed (somewhere like .../lib/python2.7/site-packages/zipline). Usually "no module named XXX" is caused by you sys.path
doesn't contain the path you installed zipline. You should just add your zipline path into sys.path
. Also use anaconda is good for zipline (http://www.zipline.io/install.html), so as to keep the environment tidy and clean.
来源:https://stackoverflow.com/questions/37696727/zipline-import-error-no-module-named-zipline-transforms