jankrepl / deepdow

Portfolio optimization with deep learning.
https://deepdow.readthedocs.io
Apache License 2.0
874 stars 136 forks source link

Trouble with cvxpy #117

Open rukawa917 opened 2 years ago

rukawa917 commented 2 years ago

I seem to have error in importing cvxpy for some reason.

I have looked for solutions, but I can't find the solution. Below is the error I got. I am using PyCharm and my OS is Mac.

Traceback (most recent call last): File "/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/data_prep.py", line 5, in from deepdow.benchmarks import Benchmark, OneOverN, Random File "/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/deepdow/benchmarks.py", line 5, in from cvxpylayers.torch import CvxpyLayer File "/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/cvxpylayers/torch/init.py", line 1, in from cvxpylayers.torch.cvxpylayer import CvxpyLayer # noqa: F401 File "/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/cvxpylayers/torch/cvxpylayer.py", line 1, in import diffcp File "/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/diffcp/init.py", line 3, in from diffcp.cone_program import solve_and_derivative, \ File "/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/diffcp/cone_program.py", line 3, in import diffcp.cones as cone_lib File "/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/diffcp/cones.py", line 6, in from _diffcp import dprojection, project_exp_cone, Cone, ConeType ImportError: dlopen(/Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/_diffcp.cpython-38-darwin.so, 2): Library not loaded: @rpath/libc++.1.dylib Referenced from: /Users/chriskang/Desktop/OneDrive - HKUST Connect/Pycharm/2021_Toy/DeepDow/venv/PycharmProjects/VirtualEnvList/lib/python3.8/site-packages/_diffcp.cpython-38-darwin.so Reason: image not found

Please help

jankrepl commented 2 years ago

Hey there!

Looking at the traceback I think this issue has to do with incorrect installation of cvxpylayers and more specifically it's dependency diffcp.

I would image that if you try to run the following import inside of Python you get the same error, right?

import diffcp.cones as cone_lib

Anyway, if that is the case, I would definitely encourage you to read through issues in the following repos. And if none of them addresses your problem you should probably create a new issue.

If you figure out the problem, feel free to close this issue and potential describe what measures you took:)