robertmartin8 / PyPortfolioOpt

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

Failure importing "plotting" #577

Closed MacarocoFonseca closed 8 months ago

MacarocoFonseca commented 8 months ago

I am trying to import plotting method from pypfopt as follows:

`import yfinance as yf import pandas as pd import numpy as np from datetime import datetime

import matplotlib.pyplot as plt from pypfopt.efficient_frontier import EfficientFrontier from pypfopt import risk_models, expected_returns, plotting from pypfopt.discrete_allocation import DiscreteAllocation, get_latest_prices`

but I am getting the following error:

`FileNotFoundError Traceback (most recent call last) File ~/Desktop/6-Github/learning/portfolio-optimization/.venv/lib/python3.9/site-packages/matplotlib/style/core.py:137, in use(style) 136 try: --> 137 style = _rc_params_in_file(style) 138 except OSError as err:

File ~/Desktop/6-Github/learning/portfolio-optimization/.venv/lib/python3.9/site-packages/matplotlib/init.py:866, in _rc_params_in_file(fname, transform, fail_on_error) 865 rc_temp = {} --> 866 with _open_file_or_url(fname) as fd: 867 try:

File /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py:119, in _GeneratorContextManager.enter(self) 118 try: --> 119 return next(self.gen) 120 except StopIteration:

File ~/Desktop/6-Github/learning/portfolio-optimization/.venv/lib/python3.9/site-packages/matplotlib/init.py:843, in _open_file_or_url(fname) 842 fname = os.path.expanduser(fname) --> 843 with open(fname, encoding='utf-8') as f: 844 yield f

FileNotFoundError: [Errno 2] No such file or directory: 'seaborn-deep'

The above exception was the direct cause of the following exception: ... 142 f"styles are listed in style.available)") from err 143 filtered = {} 144 for k in style: # don't trigger RcParams.getitem('backend')

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)`

Operating system, python version, PyPortfolioOpt version e.g MacOS 14.2.1, python 3.9.18, PyPortfolioOpt 1.5.5

88d52bdba0366127fffca9dfa93895 commented 8 months ago

Hi @MacarocoFonseca, this was fixed on master branch. Could you please install directly from that, like this pip install https://github.com/robertmartin8/PyPortfolioOpt.git.

Feel free to re-open this ticket.