alpacahq / alpacahq/alpaca-py

[Bug]: Cannot import alpaca_py in R using reticulate

未关闭
#568 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
1.5k
派生
398
平均合并
1 天 16 小时
30 天内合并 PR
6

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。