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

mosek.Error: rescode.err_missing_license_file(1008): License cannot be located. The default search path is ';C:\Users\UserName\mosek\mosek.lic;'. #547

Closed apokrif333 closed 1 year ago

apokrif333 commented 1 year ago

Describe the bug If I run EfficientFrontier.efficient_risk() or EfficientFrontier.efficient_return() or plotting.plot_efficient_frontier(EfficientFrontier, ax=ax, show_assets=True) I get the Error "mosek.Error: rescode.err_missing_license_file(1008): License cannot be located. The default search path is ';C:\Users\UserName\mosek\mosek.lic;'."

Full Error plotting.plot_efficient_frontier(ef, ax=ax, show_assets=True) File "D:\venv3.10\lib\site-packages\pypfopt\plotting.py", line 261, in plot_efficient_frontier ef_param_range = _ef_default_returns_range(opt, points) File "D:\venv3.10\lib\site-packages\pypfopt\plotting.py", line 164, in _ef_default_returns_range max_ret = ef_maxret._max_return() File "D:\venv3.10\lib\site-packages\pypfopt\efficient_frontier\efficient_frontier.py", line 218, in _max_return res = self._solve_cvxpy_opt_problem() File "D:\venv3.10\lib\site-packages\pypfopt\base_optimizer.py", line 305, in _solve_cvxpy_opt_problem self._opt.solve( File "D:\venv3.10\lib\site-packages\cvxpy\problems\problem.py", line 481, in solve return solve_func(self, *args, *kwargs) File "D:\venv3.10\lib\site-packages\cvxpy\problems\problem.py", line 1016, in _solve solution = solving_chain.solve_via_data( File "D:\venv3.10\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py", line 361, in solve_via_data return self.solver.solve_via_data(data, warm_start, verbose, File "D:\venv3.10\lib\site-packages\cvxpy\reductions\solvers\conic_solvers\mosek_conif.py", line 238, in solve_via_data task.optimize() File "D:\venv3.10\lib\site-packages\mosek__init.py", line 10777, in optimize return self.optimizetrm__1(args,**kwds) File "D:\venv3.10\lib\site-packages\mosek__init.py", line 10766, in optimizetrm__1 raise Error(rescode(_res_optimizetrm),_msg_optimizetrm) mosek.Error: rescode.err_missing_license_file(1008): License cannot be located. The default search path is ';C:\Users\Alex\mosek\mosek.lic;'.

Process finished with exit code 1

Code sample

from pypfopt import EfficientFrontier
ef = EfficientFrontier(mu, S)
weights = ef.efficient_return(0.11)

Operating system, python version, PyPortfolioOpt version Windows 10 Pro 20H2, python 3.10, PyPortfolioOpt 1.5.5

88d52bdba0366127fffca9dfa93895 commented 1 year ago

Hi @apokrif333, seem like you are using mosek optimizer and it cannot find your license. You could:

  1. Buy a license and fix the path, the default license path is C:\Users\Alex\mosek\mosek.lic
  2. Use other free optimizers