Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot import alpaca_py in R using reticulate #568

Open
2 tasks done
cwalker912 opened this issue Feb 23, 2025 · 0 comments
Open
2 tasks done

[Bug]: Cannot import alpaca_py in R using reticulate #568

cwalker912 opened this issue Feb 23, 2025 · 0 comments

Comments

@cwalker912
Copy link

Is there an existing issue for this?

  • 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

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?

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant