【问题标题】:Module not Found: zipline import未找到模块:zipline 导入
【发布时间】:2018-08-01 11:37:02
【问题描述】:

从行获取以下堆栈跟踪:

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 子系统

Pyhon 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 返回

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

【问题讨论】:

  • 你试过pip install trading-calendars吗?
  • @FlyingTeller 是的,模块无法通过pip找到/不可用
  • on PyPi,不知道为什么你的pip声称找不到。您可以从github 下载并安装它
  • @FlyingTeller 我想通了,谢谢你的帮助
  • 没关系,刚刚看到 PyPi 版本仅适用于 Python 3.5。但是你仍然可以手动安装

标签: python module zipline


【解决方案1】:

问题是由于multiple versions of python 的存在而出现的。在zipline/zipline repo 中使用python -m pip install &lt;packages&gt; 命令,我能够在python shell 中成功执行import zipline

【讨论】:

    猜你喜欢
    • 2021-11-15
    • 1970-01-01
    • 1970-01-01
    • 2020-10-23
    • 2020-01-20
    • 2020-10-01
    • 2021-11-18
    • 2020-08-11
    相关资源
    最近更新 更多