Error trying to use with R encountered during "py_install("fasterrisk", pip=TRUE, envname="FasterRisk-environment")"
Hi there,
I'm trying to get this running in R. I don't know anything about Python. I was trying to follow your R instructions.
** I installed Python (had to do this from Python web site - reticulate didn't work, installed latest version 3.12.0)**
Executed the following - and both worked (with version = "3.12.0")
virtualenv_create(envname="FasterRisk-environment", version = version)
use_virtualenv("FasterRisk-environment")
Then tried to install FasterRisk per instructions
py_install("fasterrisk", pip=TRUE, envname="FasterRisk-environment")
...and encountered the error reported below. Like I said - I have don't know anything about Python, so perhaps this is something simple/obvious.
Using virtual environment "FasterRisk-environment" ...
"C:/Users/mschwartz/Documents/.virtualenvs/FasterRisk-environment/Scripts/python.exe" -m pip install --upgrade --no-user fasterrisk Collecting fasterrisk Downloading fasterrisk-0.1.7-py3-none-any.whl (20 kB) Requirement already satisfied: numpy<2.0.0,>=1.23.3 in c:\users\mschwa~1\docume~1\virtua~1\faster~1\lib\site-packages (from fasterrisk) (1.26.2) Collecting pandas==1.5.2 (from fasterrisk) Downloading pandas-1.5.2.tar.gz (5.2 MB) ---------------------------------------- 5.2/5.2 MB 4.5 MB/s eta 0:00:00 Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: still running... Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Collecting requests<3.0.0,>=2.28.1 (from fasterrisk) Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB) Collecting scikit-learn==1.2.0 (from fasterrisk) Downloading scikit-learn-1.2.0.tar.gz (7.2 MB) ---------------------------------------- 7.2/7.2 MB 5.3 MB/s eta 0:00:00 Installing build dependencies: started Installing build dependencies: still running... Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'error' error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [33 lines of output] Traceback (most recent call last): File "C:\Users\MSCHWA~1\DOCUME~1\VIRTUA~1\FASTER~1\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main() File "C:\Users\MSCHWA~1\DOCUME~1\VIRTUA~1\FASTER~1\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MSCHWA~1\DOCUME~1\VIRTUA~1\FASTER~1\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 112, in get_requires_for_build_wheel backend = _build_backend() ^^^^^^^^^^^^^^^^ File "C:\Users\MSCHWA~1\DOCUME~1\VIRTUA~1\FASTER~1\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 77, in build_backend obj = import_module(mod_path) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MSCHWA~1\AppData\Local\Programs\Python\PYTHON~1\Lib\importlib_init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File " ", line 1381, in _gcd_import File " ", line 1354, in _find_and_load File " ", line 1304, in _find_and_load_unlocked File " ", line 488, in _call_with_frames_removed File " ", line 1381, in _gcd_import File " ", line 1354, in _find_and_load File " ", line 1325, in _find_and_load_unlocked File " ", line 929, in load_unlocked File " ", line 994, in exec_module File " .py", line 2172, in", line 488, in call_with_frames_removed File "C:\Users\mschwartz\AppData\Local\Temp\pip-build-env-gdkahper\overlay\Lib\site-packages\setuptools_init.py", line 16, in import setuptools.version File "C:\Users\mschwartz\AppData\Local\Temp\pip-build-env-gdkahper\overlay\Lib\site-packages\setuptools\version.py", line 1, in import pkg_resources File "C:\Users\mschwartz\AppData\Local\Temp\pip-build-env-gdkahper\overlay\Lib\site-packages\pkg_resources_init register_finder(pkgutil.ImpImporter, find_on_path) ^^^^^^^^^^^^^^^^^^^ AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'? [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip. Error: Error installing package(s): "fasterrisk"
OK - I downgraded to 3.9.12, and managed to get that part to work - sorry for the clutter.
However, a few steps later in your instructions I encountered the following while trying to download the sample data:
Error in py_get_attr_impl(x, name, silent) : AttributeError: module 'fasterrisk' has no attribute 'utils' Run
reticulate::py_last_error()for details.
I ran reticulate::py_last_error() and got the following:
── Python Exception Message ──────────────────────────────────────────────────────────────────────────────────────── AttributeError: module 'fasterrisk' has no attribute 'utils'
── R Traceback ───────────────────────────────────────────────────────────────────────────────────────────────────── ▆
- ├─fasterrisk$utils
- └─reticulate:::
$.python.builtin.module(fasterrisk, utils)- └─reticulate:::
$.python.builtin.object(x, name)└─reticulate:::py_get_attr_or_item(x, name, TRUE)└─reticulate::py_get_attr(x, name)└─reticulate:::py_get_attr_impl(x, name, silent)
So, it seems (knowing nothing about Python) that "fasterrisk" is missing an attribute named "utils"