1

I'm a newbie to zipline and I'm trying to reproduce this example loosely. It calls for modifying a file .zipline/extension.py. Fat luck, I do not have this file.

Now, I can do (from inside the virtualenv):

(Mony_games) me@me-ThinkPad-T470p:~/$ ipython
import zipline
zipline.utils.paths.default_extension()

But this points to

'/home/me/.zipline/extension.py'

which doesn't exist. Do I have to create it? If so, where: I'm a bit confused because I'm using a virtualenv, so:

import inspect
inspect.getfile(zipline)
'/home/me/virtualenvs/Mony_games/lib/python3.5/site-packages/zipline/__init__.py'
user189035
  • 5,589
  • 13
  • 52
  • 112
  • have you tried `/home/me/virtualenvs/bin/pip install zipline`? install it using your virtualenv pip – Haifeng Zhang Dec 01 '17 at 22:23
  • `zipline` *is* already installed --using virtualenv-- (I'm doing `import zipline` inside my virtualenv and it works). Or maybe I do not understand your comment. Sorry, can you try to explain a bit? – user189035 Dec 01 '17 at 22:24

2 Answers2

1

Your virtualenv doesn't know anything about ipython. To verify, open ipython and enter:

import sys
sys.executable

The python executable will be your global python.

If you put your script in a file, you can execute the file with python myfile.py and that will use the python executable in your virtualenv.

thebjorn
  • 26,297
  • 11
  • 96
  • 138
  • Are you sure you put your answer in the right place? I really don't understand the connection between my question and your answer. – user189035 Dec 02 '17 at 00:28
  • You say zipline is installed in your virtualenv, but you use ipython to demonstrate your problem. ipython uses the global python (not the python installed in your virtualenv) and all of _its_ packages. The solution is either to install every package in the global python and use it from there, or write your code to .py files and call them with the virtualenv installed python, or hack ipython so it understands virtualenvs (eg. https://stackoverflow.com/questions/20327621/calling-ipython-from-a-virtualenv) – thebjorn Dec 02 '17 at 01:37
1

it's okay. virtualenv or not, this file should be where

import zipline
zipline.utils.paths.default_extension()

points to, which in my case is:

'/home/me/.zipline/extension.py'
user189035
  • 5,589
  • 13
  • 52
  • 112