shepherdpp / qteasy

a python-based fast quantitative investment module
BSD 3-Clause "New" or "Revised" License
73 stars 28 forks source link

ImportError: Numba needs NumPy 1.22 or greater. Got NumPy 1.21. #136

Closed roc138 closed 6 months ago

roc138 commented 7 months ago

运行代码 import qteasy as qt

下载股票数据 (从2023年1月1日到2023年12月31日之间的所有股票数据)

qt.refill_data_source(tables='stock_daily', start_date='20240101', end_date='20240402')

报错

C:\ProgramData\anaconda3\envs\python38\python.exe C:\Users\Administrator\PycharmProjects\qteasy-1\qteasy-data-t2.py Traceback (most recent call last): File "C:\Users\Administrator\PycharmProjects\qteasy-1\qteasy-data-t2.py", line 1, in import qteasy as qt File "C:\ProgramData\anaconda3\envs\python38\lib\site-packages\qteasy__init.py", line 23, in import qteasy.utilfuncs File "C:\ProgramData\anaconda3\envs\python38\lib\site-packages\qteasy\utilfuncs.py", line 19, in from numba import njit File "C:\ProgramData\anaconda3\envs\python38\lib\site-packages\numba__init__.py", line 55, in _ensure_critical_deps() File "C:\ProgramData\anaconda3\envs\python38\lib\site-packages\numba\init__.py", line 40, in _ensure_critical_deps raise ImportError(msg) ImportError: Numba needs NumPy 1.22 or greater. Got NumPy 1.21.

进程已结束,退出代码为 1

roc138 commented 7 months ago

执行 pip install numba==0.57,numba退到0.57后没这个"ImportError: Numba needs NumPy 1.22 or greater. Got NumPy 1.21."报错了。 但还是有另外的报错。 C:\ProgramData\anaconda3\envs\python38\python.exe C:\Users\Administrator\PycharmProjects\qteasy-1\qteasy-data-t2.py C:\ProgramData\anaconda3\envs\python38\lib\site-packages\qteasy__init__.py:136: UserWarning: trade calendar is not loaded, some utility functions may not work properly, to download trade calendar, run "qt.refill_data_source(tables='trade_calendar')" warnings.warn(f'trade calendar is not loaded, some utility functions may not work ' Filling data source db:mysql://localhost@3306/qt_db ... Traceback (most recent call last): File "C:\Users\Administrator\PycharmProjects\qteasy-1\qteasy-data-t2.py", line 4, in qt.refill_data_source(tables='stock_daily', start_date='20230101', end_date='20231231') File "C:\ProgramData\anaconda3\envs\python38\lib\site-packages\qteasy\core.py", line 699, in refill_data_source data_source.refill_local_source(**kwargs) File "C:\ProgramData\anaconda3\envs\python38\lib\site-packages\qteasy\database.py", line 4797, in refill_local_source elif pd.to_datetime('today') >= pd.to_datetime(latest_calendar_date): TypeError: '>=' not supported between instances of 'Timestamp' and 'NoneType'

进程已结束,退出代码为 1

roc138 commented 7 months ago

经过搜索,发现了博客园中的方法 https://www.cnblogs.com/qteasy/p/18064894 qt.refill_data_source(tables='trade_calendar, stock_basic, index_basic')

还是有些报错,可能windows问题,我试试linux吧

roc138 commented 7 months ago

1.17 版本解决问题了,用起来顺了,太爽了。

shepherdpp commented 7 months ago

之前版本的qteasy一直在python3.8环境中开发,pandasnumpynumba的版本都相对较低,高版本的numba、numpy调整了一些功能,导致运行会报错。 对此从1.1.7版本开始,我特别注意了qteasy对高版本的python以及最新版本numba/numpy的兼容性。目前在python3.12及以下版本中都可以安装及运行。更多的兼容性测试也正在python3.7~3.12的所有版本上同时运行,如果发现还有兼容性问题也会在后续的patch中修复,敬请期待!

shepherdpp commented 6 months ago

从v1.1.7开始,以后版本的qteasy都经测试能在python3.7一直到3.12的环境中运行,如果您遇到同样的问题,请升级qteasy到最新版本:

$ pip intall tushare -U

本问题已解决,我将关闭此Issue