robertmartin8 / PyPortfolioOpt

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

Can't import plotting, get 'seaborn-deep' is not a valid package style #567

Closed wayner9 closed 7 months ago

wayner9 commented 8 months ago

Describe the bug whenever I have "from pypfopt import plotting" in my code it throws an error - see below

Code sample from pypfopt import plotting

Operating system, python version, PyPortfolioOpt version Windows 10, Python 3.11, not sure how to know what PyPortfolioOpt version

Additional context

>>> 
from pypfopt import plotting
Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\style\core.py", line 137, in use
    style = _rc_params_in_file(style)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\__init__.py", line 879, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\__init__.py", line 856, in _open_file_or_url
    with open(fname, encoding='utf-8') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'seaborn-deep'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pypfopt\plotting.py", line 21, in <module>
    plt.style.use("seaborn-deep")
  File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\style\core.py", line 139, in use
    raise OSError(
OSError: 'seaborn-deep' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)
>>>
88d52bdba0366127fffca9dfa93895 commented 7 months ago

@wayner9 please see this ticket: https://github.com/robertmartin8/PyPortfolioOpt/issues/562

wayner9 commented 7 months ago

@wayner9 please see this ticket: #562

Thanks, but has this been fixed in the latest version? It appears that the most recent update was done in May of this year, I just started using PyPortfolioOpt in October, and I installed using Pip in the last month or so, so presumably I am using the latest version.

Does this mean that on whatever computer or VENV I use for PyPortfolioOpt that I have to go into this file and change the seaborn-dep reference?