facebookincubator / GeoLift

GeoLift is an end-to-end geo-experimental methodology based on Synthetic Control Methods used to measure the true incremental effect (Lift) of ad campaign.
https://facebookincubator.github.io/GeoLift/
MIT License
175 stars 54 forks source link

encountered RRuntimeError: Error in { : task 1 failed - "shared object ‘osqp.so’ not found" #194

Open xiang-liii opened 1 month ago

xiang-liii commented 1 month ago

Bug description

I am following the github python have followed the instructions in README.md and trying to test run demo.py

This Error occurred as I run the file

xli@Xiangs-MacBook-Pro GeoLiftPython % /Users/xli/.pyenv/versions/3.11.4/bin/python "/Users/xli/Strava Git/analytics/sandbox/xiangli/GeoLift-GeoLiftPython/GeoLiftPython/demo.py"
  location    Y       date
0 new york 3300 2021-01-01
1 new york 3202 2021-01-02
2 new york 4138 2021-01-03
3 new york 3716 2021-01-04
4 new york 3270 2021-01-05
5 new york 3260 2021-01-06

R[write to console]: ##################################
#####       Summary       #####
##################################

* Raw Number of Locations: 40
* Time Periods: 90
* Final Number of Locations (Complete): 40

<IPython.core.display.Image object>
The GeoPlot chart was saved in Plots/GeoPlot_Plot_n1.png
R[write to console]: Setting up cluster.

R[write to console]: Importing functions into cluster.

R[write to console]: Attempting to load the environment ‘package:dplyr’

R[write to console]: 
Attaching package: ‘dplyr’

R[write to console]: The following objects are masked from ‘package:stats’:

    filter, lag

R[write to console]: The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

R[write to console]: Calculating which the best treatment groups are.

R[write to console]: 
Deterministic setup with 2 locations in treatment.

R[write to console]: Error in { : task 1 failed - "shared object ‘osqp.so’ not found"

Traceback (most recent call last):
  File "/Users/xli/Strava Git/analytics/sandbox/xiangli/GeoLift-GeoLiftPython/GeoLiftPython/demo.py", line 143, in <module>
    MarketSelections = GeoLift.GeoLiftMarketSelection(data = GeoTestData_PreTest,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xli/.pyenv/versions/3.11.4/lib/python3.11/site-packages/rpy2/robjects/functions.py", line 208, in __call__
    return (super(SignatureTranslatedFunction, self)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xli/.pyenv/versions/3.11.4/lib/python3.11/site-packages/rpy2/robjects/functions.py", line 131, in __call__
    res = super(Function, self).__call__(*new_args, **new_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xli/.pyenv/versions/3.11.4/lib/python3.11/site-packages/rpy2/rinterface_lib/conversion.py", line 45, in _
    cdata = function(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xli/.pyenv/versions/3.11.4/lib/python3.11/site-packages/rpy2/rinterface.py", line 869, in __call__
    raise embedded.RRuntimeError(_rinterface._geterrmessage())
rpy2.rinterface_lib.embedded.RRuntimeError: Error in { : task 1 failed - "shared object ‘osqp.so’ not found"

Session information

sessionInfo()


R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin21.6.0 (64-bit)
Running under: macOS Sonoma 14.3

Matrix products: default BLAS: /opt/homebrew/Cellar/openblas/0.3.23/lib/libopenblasp-r0.3.23.dylib LAPACK: /opt/homebrew/Cellar/r/4.3.1/lib/R/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_4.3.1


## Reproduction steps
  I have followed these steps and the error occurred after i ran demo.py

  `## Requirements 

GeoLift in Python version requires or works with:

- R version 4.0.0 or newer. Please check [R installaton](https://facebookincubator.github.io/GeoLift/docs/GettingStarted/InstallingR).

- Python version 3.7.0 or newer. Please check [Python installation](https://www.python.org/).

## Installation

The installation of GeoLift in Python version assumes that you will use pip3 as your Python package manager. If you do not use pip3, before running anything, edit the commands in setup.sh and change pip3 to your Python package manager to avoid package management issues.

### Option 1 - Work environment

Step 1: Download GeoLiftPython folder hosted on GeoLift's Github.

Step 2 (On Terminal): Located in the GeoLiftPython folder, run the commands below in your environment: 

pip3 install -r requirements.txt python3 r_lang_requirements.py


Step 2 (On Jupyter): Located in the GeoLiftPython folder, run the commands below in your environment: 

!pip3 install -r requirements.txt %run r_lang_requirements.py

xiang-liii commented 3 weeks ago

hi! wondering if there is any thoughts on this issue?

JussanN commented 3 weeks ago

Hi @xiang-liii we're working on it and let you know when we find the solution to your error. Thank you.

raphaeltamaki commented 2 weeks ago

Hello @xiang-liii , thank you for your patience For me to be of better help, could you clarify some doubts? 1) I can see you are using a Mac, at least based on your terminal. Just wanted to confirm if you followed the instructions specific to Mac, which uses the bash setup.sh file, or something else 2) Could you confirm that you were able to open the GeoLiftWalkthrough notebook and run all its cells? 3) You are using the version installed in /Users/xli/.pyenv/versions/3.11.4/bin/python, which, at least based on the name and location, doesn't feel like a virtual environment allocated only for GeoLift. Instead, it feels like you are using your base Python version. Is this the case? If so, this Python version might not have had the requirements installed.

Based on how you executed the code, it feels like the error is originated by how you tried to run it. Also,from the error message, your execution wasn't able to find the osqp.so object, which is probably a shared library from R, which gives some indication that the problem is originated by the installation/execution method

xiang-liii commented 3 days ago

hi @raphaeltamaki , thanks for taking a look!

  1. I was following option 1 only, but I tried option 2 for mac virtual environment just now and tried to run GeoLiftWalkthrough notebook, same error shown for this code chunk in jupyter notebook MarketSelections = GeoLift.GeoLiftMarketSelection(data = GeoTestData_PreTest, treatment_periods = IntVector([10,15]), N = IntVector([2, 3, 4, 5]), Y_id = "Y", location_id = "location", time_id = "time", effect_size = r.seq(0, 0.5, 0.05), lookback_window = 1, include_markets = StrVector(['chicago']), exclude_markets = StrVector(['honolulu']), holdout = IntVector([0.5,1]), cpic = 7.50, budget = 100000, alpha = 0.1, Correlations = True, fixed_effects = True, side_of_test = "two_sided")

  2. same error shown for the GeoLiftWalkThrough notebook

  3. yes i was using option one which is the work enviornment, but same alert shown for virtual environment as I illustrated in 1)

Let me know if any findings, appreciate your help!