alpacahq / alpacahq/alpaca-py

[Bug]: Cannot import alpaca_py in R using reticulate

Offen
#568 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
1.5k
Forks
397
Ø Merge
1 T. 16 Std.
Gemergte PRs (30 T.)
6

Beschreibung

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Current Behavior

When I use the reticulate R package to install alpaca-py, I can see the package in the virtualenv, but cannot import. I believe this is a hyphen in the package name issue. When I import other packages with hyphens in their names changing the hyphen to an underscore allows the package to be properly imported by reticulate into R. This is not the case with alpaca-py. Thank you for your time here.

Example:
> library(reticulate)
> use_virtualenv("r-reticulate-alpaca")
>virtualenv_install("r-reticulate-alpaca", "alpaca-py")
...
> py_list_packages()
package version requirement
1 alpaca-py 0.38.0 alpaca-py==0.38.0
2 annotated-types 0.7.0 annotated-types==0.7.0
3 certifi 2025.1.31 certifi==2025.1.31
4 charset-normalizer 3.4.1 charset-normalizer==3.4.1
5 idna 3.10 idna==3.10
6 msgpack 1.1.0 msgpack==1.1.0
7 numpy 2.2.3 numpy==2.2.3
8 pandas 2.2.3 pandas==2.2.3
...
> x <- import ("alpaca_py")
Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'alpaca_py'
Run `reticulate::py_last_error()` for details.
> y <- reticulate::import("charset_normalizer")
> z <- reticulate::import("annotated_types")

### Expected Behavior

When I do:
library(reticulate)
use_virtualenv("r-reticulate-alpaca")
x <- import ("alpaca_py")
I expect the package to be loaded correctly into the environment.

### SDK Version I encountered this issue in

0.38.0

### Steps To Reproduce

```markdown
In R-4.4.2 running in R studio Build 375, with R reticulate package 1.39.0:

library(reticulate)
# set up a virtualenv
use_virtualenv("r-reticulate-alpaca")
# install alpaca-py into the venv
virtualenv_install("r-reticulate-alpaca", "alpaca-py")
#verify install
py_list_packages()
import the python package into R environment
x <- import ("alpaca_py")
Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'alpaca_py'

# also does not work with hyphen
x <- import ("alpaca-py")
Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'alpaca-py'
```

### Filled out the Steps to Reproduce section?

- [x] I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

### Anything else?

_No response_

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.