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

Reticulate not detecting python3-venv even though it is installed so cant create virtualenvs #1495

Closed
paulm66 opened this issue Oct 20, 2023 · 4 comments · Fixed by #1496
Closed

Comments

@paulm66
Copy link

paulm66 commented Oct 20, 2023

When I install reticulate (in RStudio 2023.09.1) and try to create a virtualenv I see the following error message:

reticulate::virtualenv_create(envname = "test", python = "/usr/bin/python3.10")
Error: Tools for managing Python virtual environments are not installed.

Install venv with:
$ sudo apt-get install python3-venv

When I try to install the above package Ubuntu (Ubuntu 22.04.3 LTS) tells me it is already installed. Digging into the reticulate code it looks like the issue might be this line here:

if (!any(grepl("^python[0-9.]*-venv$", system("dpkg -l", intern = TRUE))))

The regex uses start and end line characters (^ $) that seem to cause it to fail when detecting the installed package.

My session description is attached below

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8
[6] LC_MESSAGES=en_GB.UTF-8 LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_4.1.2 here_1.0.1 Matrix_1.4-0 rprojroot_2.0.3 tools_4.1.2 rappdirs_0.3.3 Rcpp_1.0.11
[8] reticulate_1.34.0 grid_4.1.2 jsonlite_1.8.7 rlang_1.1.1 png_0.1-8 lattice_0.20-45

@t-kalinowski
Copy link
Member

What is the output of system("dpkg -l", intern = TRUE) that you are seeing?

@paulm66
Copy link
Author

paulm66 commented Oct 20, 2023

The output of that is pretty large. I slimmed it down by searching for anything matching venv:

system("dpkg -l *venv*", intern = TRUE)
[1] "Desired=Unknown/Install/Remove/Purge/Hold"
[2] "| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend"
[3] "|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)"
[4] "||/ Name Version Architecture Description"
[5] "+++-===============-=======================-============-============================================================================="
[6] "ii python3-venv 3.10.6-1~22.04 amd64 venv module for python3 (default python3 version)"
[7] "ii python3.10-venv 3.10.12-1~22.04.2 amd64 Interactive high-level object-oriented language (pyvenv binary, version 3.10)"
[8] "rc python3.8-venv 3.8.10-0ubuntu1~20.04.4 amd64 Interactive high-level object-oriented language (pyvenv binary, version 3.8)"
[9] "rc python3.9-venv 3.9.7-2build1 amd64 Interactive high-level object-oriented language (pyvenv binary, version 3.9)"

@t-kalinowski
Copy link
Member

Tentative fix in fix/ubuntu22-venv, can you please confirm it works for you?

remotes::install_github("rstudio/reticulate@fix/ubuntu22-venv")

@paulm66
Copy link
Author

paulm66 commented Oct 20, 2023

That works for me. Output below:

reticulate::virtualenv_create(envname = "test", python = "/usr/bin/python3.10")
Using Python: /usr/bin/python3.10
Creating virtual environment 'test' ...
+ /usr/bin/python3.10 -m venv /home/paul/.virtualenvs/test
Done!
Installing packages: pip, wheel, setuptools
+ /home/paul/.virtualenvs/test/bin/python -m pip install --upgrade pip wheel setuptools
.......
Virtual environment 'test' successfully created.

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants