alpacahq / alpacahq/alpaca-py

[Bug]: Cannot import alpaca_py in R using reticulate

Abierto
#568 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
1.5k
Forks
398
Merge medio
1 d 16 h
PR fusionados (30 d)
6

Descripción

### 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_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.