mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.88k stars 856 forks source link

C extension error when running buy_and_hold_backtest.py #261

Closed tansc1990 closed 4 years ago

tansc1990 commented 6 years ago

Hi,

I was trying out the README.md documentation and i encountered this error when running "python buy_and_hold_backtest.py"

`RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa Traceback (most recent call last): File "/home/emperor/venv/qstraderp3/lib/python3.6/site-packages/pandas/init.py", line 25, in from pandas import hashtable, tslib, lib ImportError: numpy.core.multiarray failed to import

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "buy_and_hold_backtest.py", line 7, in from qstrader.trading_session import TradingSession File "/home/emperor/venv/qstraderp3/lib/python3.6/site-packages/qstrader/trading_session.py", line 5, in from .price_handler.yahoo_daily_csv_bar import YahooDailyCsvBarPriceHandler File "/home/emperor/venv/qstraderp3/lib/python3.6/site-packages/qstrader/price_handler/yahoo_daily_csv_bar.py", line 3, in import pandas as pd File "/home/emperor/venv/qstraderp3/lib/python3.6/site-packages/pandas/init.py", line 31, in "extensions first.".format(module)) ImportError: C extension: umpy.core.multiarray failed to import not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.`

I am running on an Ubuntu 18.04 machine, are there any possible solutions/alternatives?

JamesKBowler commented 6 years ago

without digging into the details too much, I would assume its a numpy compatibility issue with Ubuntu 18.04.

18.04 is bleeding edge, best open up an issue on numpy's page? Or try on 16.04

Also, have you seen this? https://stackoverflow.com/questions/30761152/how-to-solve-import-error-for-pandas

or this

https://github.com/pandas-dev/pandas/issues/18281

Cheers James

tansc1990 commented 6 years ago

Thank you James! It works fine once I follow the instructions on the second link on #18281

JamesKBowler commented 6 years ago

You are welcome, happy to help.