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

Error: ModuleNotFoundError: No module named 'rpytools' #1570

Open
jrausch12 opened this issue Apr 1, 2024 · 3 comments
Open

Error: ModuleNotFoundError: No module named 'rpytools' #1570

jrausch12 opened this issue Apr 1, 2024 · 3 comments

Comments

@jrausch12
Copy link

Issue: Error: ModuleNotFoundError: No module named 'rpytools'

Summary: It seems that when using pyenv to manage python versions and having RETICULATE_PYTHON set to the proper pyenv python install location, it prevents reticulate from installing the accompanying rpytools.

Steps to reproduce:

  • Be on Windows 10
  • Be on R version 4.1.1 or higher
  • Have pyenv installed and have it be the only one managing your python exes (i.e remove all other system environmental variables referencing local python installs and only have pyenv set)
  • Install reticulate from compiled or source, does not matter
  • Attempt reticulate::repl_python()
  • Observe error
@t-kalinowski
Copy link
Member

t-kalinowski commented Apr 2, 2024

Hi, thanks for reporting. My guess is that, most likely, this is something specific to your setup. Many people have been using reticulate successfully on Windows with pyenv.

Note that rpytools is not installed in the Python library, it is included in the installed R package, and that location is dynamically placed on the Python path sys.path when reticulate initializes Python.

Do you perhaps have PYTHONPATH set or something similar? What is the output of import sys; print(sys.path)? Is there any additional output shown. Are there any differences if you load python directly, or via reticulate, outside an IDE (e.g., in cmd.exe)?

@jrausch12
Copy link
Author

I do not have PYTHONPATH set. Here's the output of print(sys.path) for a cmd instance which is correctly running 3.10.11 as managed by pyenv

['', 'C:\\Users\\jrauscher\\.pyenv\\pyenv-win\\versions\\3.10.11\\python310.zip', 'C:\\Users\\jrauscher\\.pyenv\\pyenv-win\\versions\\3.10.11\\DLLs', 'C:\\Users\\jrauscher\\.pyenv\\pyenv-win\\versions\\3.10.11\\lib', 'C:\\Users\\jrauscher\\.pyenv\\pyenv-win\\versions\\3.10.11', 'C:\\Users\\jrauscher\\.pyenv\\pyenv-win\\versions\\3.10.11\\lib\\site-packages']

How exactly is reticulate initializing Python? That may give me some clues to potential conflicts with pyenv against local python installations.

@t-kalinowski
Copy link
Member

Reticulate inserts rpytools on the Python path here:

system.file("python", package = "reticulate"),

Stepping through reticulate:::initialize_python() might reveal why it's not working.

debugonce(reticulate:::initialize_python)
py_eval("1")

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

2 participants