找不到模块:zipline 导入

Module not Found: zipline import

从行中获取以下堆栈跟踪:

zipline/zipline/__init__.py", line 17, in <module>
    import numpy as np
ImportError: No module named 'numpy'

然而,当我检查 pip list

pip list | grep numpy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
numpy             1.16.6

这一切发生在我克隆到 Quantopian/Zipline Github Repo 之后。 我在 github 上打开了一个 issue,在此编辑之后,我将搜索 SO 以查找我遗漏的任何明显内容。

环境

WSL Ubunut 子系统

派洪 3.5.5

位数:64

通过以下方式安装依赖项 sudo apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev

点数列表

alembic           1.4.2
asn1crypto        0.24.0
bcolz             0.12.1
Bottleneck        1.3.2
certifi           2019.11.28
chardet           3.0.4
click             7.1.1
contextlib2       0.6.0.post1
cycler            0.10.0
cyordereddict     1.0.0
Cython            0.29.15
decorator         4.4.2
empyrical         0.5.3
enum34            1.1.6
funcsigs          1.0.2
idna              2.6
intervaltree      3.0.2
ipaddress         1.0.17
itable            0.0.1
keyring           10.6.0
Logbook           1.5.3
lru-dict          1.1.6
lxml              4.5.0
Mako              1.1.2
MarkupSafe        1.1.1
matplotlib        2.2.4
mercurial         4.5.3
mock              3.0.5
multipledispatch  0.6.0
networkx          1.11
numexpr           2.7.1
numpy             1.16.6
pandas            0.22.0
pandas-datareader 0.8.1
patsy             0.5.1
pinkfish          0.5.1
pip               19.3.1
pycrypto          2.6.1
pygobject         3.26.1
python-dateutil   2.8.1
python-editor     1.0.4
pytz              2019.3
pyxdg             0.25
requests          2.22.0
requests-file     1.4.3
scipy             1.2.2
SecretStorage     2.3.1
setuptools        39.0.1
six               1.14.0
sortedcontainers  2.1.0
SQLAlchemy        1.3.15
statsmodels       0.11.0
tables            3.5.2
toolz             0.10.0
trading-calendars 1.11.5
urllib3           1.25.7
wheel             0.30.0
zipline           1.3.0
WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

更新

运行 作为脚本,sudo python test.py returns

File "test.py", line 1, in <module>
    import zipline
  File "../zipline/zipline/__init__.py", line 29, in <module>
    from .utils.run_algo import run_algorithm
  File "../zipline/zipline/utils/run_algo.py", line 17, in <module>
    from zipline.data import bundles
  File "../zipline/zipline/data/bundles/__init__.py", line 2, in <module>
    from . import quandl  # noqa
  File "../zipline/zipline/data/bundles/quandl.py", line 17, in <module>
    from . import core as bundles
  File "../zipline/zipline/data/bundles/core.py", line 14, in <module>
    from ..adjustments import SQLiteAdjustmentReader, SQLiteAdjustmentWriter
  File "../zipline/zipline/data/adjustments.py", line 24, in <module>
    from ._adjustments import load_adjustments_from_sqlite
ImportError: No module named _adjustments

问题的出现是由于 multiple versions of python 的存在。使用 zipline/zipline 存储库中的 python -m pip install <packages> 命令,我能够在 python shell

中成功执行 import zipline