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

e.g Could not install on Windows Anaconda [replace with your environment] #540

Closed jrinne314 closed 1 year ago

jrinne314 commented 1 year ago

Operating system, environment, python version Macbook Pro M2 pro chip with new (repeated) install of Anaconda for Apple Silicone What you tried pip install pyportfolioopt

Error message


Copy paste the terminal message inside the backticks.
``Successfully installed pandas-2.0.2 pyportfolioopt-1.5.5 python-dateutil-2.8.2 pytz-2023.3 six-1.16.0 tzdata-2023.3
(PyPortfolioOpt_env) JamesRinne@Jamess-MacBook-Pro ~ % python
Python 3.11.3 | packaged by conda-forge | (main, Apr  6 2023, 08:58:31) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyportfolioopt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyportfolioopt'
`
jrinne314 commented 1 year ago

BTW, Pip list does bring up pyportfolioopt as well as cvxopt and cvxpy. >>> import pyportfolioopt Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'pyportfolioopt'

cvxopt 1.3.1 cvxpy 1.3.1 ecos 2.0.11 idna 3.4 numpy 1.24.3 osqp 0.6.3 packaging 23.1 pandas 2.0.2 pip 23.1.2 platformdirs 3.5.1 pooch 1.7.0 pyportfolioopt 1.5.5

Thank you. I use this program's output every day for my portfolio and it has worked on my new computes. So far can import other modules including: >>> import cvxopt

import cvxpy

Thank you for any help. I have a math degree but I am old and I am self-taught with Python. But usually I—with ChatGPT-can make things works.

Jim

88d52bdba0366127fffca9dfa93895 commented 1 year ago

Hi @jrinne314, you successfully installed the library, but you are using it incorrectly. You should import the pypfopt, not pyportfolioopt

Please take a look at our example here: https://github.com/robertmartin8/PyPortfolioOpt#a-quick-example

I saw that you opened 2 issues for Macos and Windows, if that solve your problem please close both of them, if not please let me know.

88d52bdba0366127fffca9dfa93895 commented 1 year ago

ref https://github.com/robertmartin8/PyPortfolioOpt/issues/539

jrinne314 commented 1 year ago

Wow!!! Meaning thank you for such a simple and effective answer. BTW if interested, my code worked before because of redundancies, I think. Import pyportfolioopt as pypfopt not good but later 'from pypfopt import plotting' may have made the program run. ChatGPT thought it was case-sensitive issue: PyPortfolioOpt. TL;DR: Much appreciated!

88d52bdba0366127fffca9dfa93895 commented 1 year ago

The 'from pypfopt import plotting import' is redundant but helpful in your case because it solves the pyportfolioopt name conflict. The ChatGPT check is not always accurate because it is not case-sensitive. However, the name of this library is a bit confusing. I spent some time thinking about it, but I couldn't come up with a better name. I know that some people will be confused by the name, like you, but it's an easy issue to fix. We can help you guys if you have any problems.

P.S. I'm glad to hear that you're using the library every day. We are too.