robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.55k stars 959 forks source link

type object 'spmatrix' has no attribute '__div__' arises when importing pypfopt #545

Closed frr717 closed 1 year ago

frr717 commented 1 year ago

When "import pypfopt", it will throw: Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help. PyDev console: using IPython 8.14.0 Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32 runfile('D:\MY_CODE\code\111.py', wdir='D:\MY_CODE\code') Traceback (most recent call last): File "C:\Users\reborn\AppData\Local\Programs\Python\Python310\lib\site-packages\IPython\core\interactiveshell.py", line 3508, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in runfile('D:\MY_CODE\code\111.py', wdir='D:\MY_CODE\code') File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev_pydev_bundle\pydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "D:\MY_CODE\code\111.py", line 1, in from pypfopt.discrete_allocation import DiscreteAllocation, get_latest_prices File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, kwargs) File "C:\Users\reborn\AppData\Local\Programs\Python\Python310\lib\site-packages\pypfopt__init__.py", line 1, in from .black_litterman import ( File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, *kwargs) File "C:\Users\reborn\AppData\Local\Programs\Python\Python310\lib\site-packages\pypfopt\black_litterman.py", line 13, in from . import base_optimizer File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, args, kwargs) File "C:\Users\reborn\AppData\Local\Programs\Python\Python310\lib\site-packages\pypfopt\base_optimizer.py", line 14, in import cvxpy as cp File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, *kwargs) File "C:\Users\reborn\AppData\Local\Programs\Python\Python310\lib\site-packages\cvxpy__init__.py", line 18, in import cvxpy.interface.scipy_wrapper File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, args, **kwargs) File "C:\Users\reborn\AppData\Local\Programs\Python\Python310\lib\site-packages\cvxpy\interface\scipy_wrapper.py", line 37, in method = getattr(spmatrix, method_name) AttributeError: type object 'spmatrix' has no attribute 'div'

Expected behavior no exception

Operating system, python version, PyPortfolioOpt version win10, python 3.10.8, PyPortfolioOpt 1.5/1.4/1.3(I tried all)