-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Description
I was trying to use rsconnect::writeManifest() with a python 3.10 virtual environment and was running into this rather opaque message when using Python 3.10
> RETICULATE_PYTHON=.venv-310/bin/python Rscript -e 'rsconnect::writeManifest()'
ℹ Capturing R dependencies
✔ Found 37 dependencies
Error in `pythonConfig()`:
! Failed to detect python environment
Caused by error:
! parse error: premature EOF
(right here) ------^
Backtrace:
▆
1. ├─rsconnect::writeManifest()
2. │ └─rsconnect:::createAppManifest(...)
3. │ └─rsconnect (local) pythonConfig(appDir)
4. │ ├─base::withCallingHandlers(...)
5. │ └─rsconnect:::inferPythonEnv(appDir, python = python, forceGenerate = forceGenerate)
6. │ └─jsonlite::fromJSON(sanitizeSystem2json(output))
7. │ └─jsonlite:::parse_and_simplify(...)
8. │ └─jsonlite:::parseJSON(txt, bigint_as_char)
9. │ └─jsonlite:::parse_string(txt, bigint_as_char)
10. └─base::.handleSimpleError(...)
11. └─rsconnect (local) h(simpleError(msg, call))
12. └─cli::cli_abort("Failed to detect python environment", parent = err)
13. └─rlang::abort(...)
Warning message:
In system2(command = python, args = args, stdout = TRUE, stderr = NULL, :
running command ''.venv-310/bin/python' '/Users/jimhester/Library/R/arm64/4.3/library/rsconnect/resources/environment.py' '/var/folders/x2/558vcp8j6_1d1c_nv62x63hc0000gn/T//Rtmp37pfjL/file1d102348912b' 2>/dev/null' had status 1
Execution halted
When I ran the python command directly I could get a better error which helped track down the issue, since the toml package is only included in the standard library in python 3.11+.
> .venv-310/bin/python /Users/jimhester/Library/R/arm64/4.3/library/rsconnect/resources/environment.py .
Traceback (most recent call last):
File "/Users/jimhester/Library/R/arm64/4.3/library/rsconnect/resources/pyproject.py", line 18, in <module>
import tomllib
ModuleNotFoundError: No module named 'tomllib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jimhester/Library/R/arm64/4.3/library/rsconnect/resources/environment.py", line 18, in <module>
import pyproject
File "/Users/jimhester/Library/R/arm64/4.3/library/rsconnect/resources/pyproject.py", line 21, in <module>
import toml as tomllib # type: ignore[no-redef]
ModuleNotFoundError: No module named 'toml'
It would be great if tomllib or the python 3.11 dependency are mentioned in DESCRIPTION as dependencies for this, also possibly the original error could be improved to point the user in the right direction.
Metadata
Metadata
Assignees
Labels
No labels