Releases: rstudio/reticulate
reticulate 1.41.0
-
New
py_require()
function for declaring Python requirements for
the current R session. For details, see updated vignettes and help:- Installing Python Packages: https://rstudio.github.io/reticulate/dev/articles/python_packages.html
- Using reticulate in an R Package: https://rstudio.github.io/reticulate/dev/articles/package.html
py_require()
help: https://rstudio.github.io/reticulate/dev/reference/py_require.html
-
New
uv_run_tool()
function for running command line tools distributed via Python packages. -
Raw R arrays and NumPy arrays with dtype "V1" ("void8") now convert between each other.
User_to_py(as.array(x))
to efficiently convert raw vectors to NumPy arrays, and
py_to_r(array$view("V1"))
to efficiently convert NumPy arrays to raw vectors. (#1734) -
Fixed an issue with using Python 3.12 on Linux (#1712, #1714).
-
Fixed an issue where
virtualenv_starter()
would not discover a
custom built Python (#1704).
reticulate 1.40.0
-
The S3 classes for some (rarely encountered) Python objects have changed.
Only Python objects with non-standard__module__
values are affected.
If a Python object’s parent class’s__module__
attribute does not resolve to a string,
reticulate:- Attempts to resolve it from the class's class, if it's a metaclass.
- If no string can be resolved, reticulate no longer implicitly prepends
'python.builtin.' as the class prefix, instead it uses just the__name__
.
(See #1686 for more context)
-
Added support for Python 3.13. Note that Python 3.13 removed support
forclassmethod
descriptors, which may affect the S3 class of
some Python objects that use metaclass properties to resolve a class’s
__module__
or__name__
attribute. (#1686, #1698) -
py_is_null_xptr()
and[[
now load delayed modules (#1688). -
Fixed error when attempting to use a python venv created with
uv
(#1678) -
Resolved an issue where
py_discover_config()
attempted to detect
Windows App Store Python installations. These are now excluded from
discovery by bothpy_discover_config()
andvirtualenv_starter()
(#1656, #1673). -
Fixed an error when converting an empty NumPy char array to R (#1662).
-
Fixed an error when using reticulate with radian (#1668, #1670).
-
Fixed a segfault encountered when running the Python session finalizer (#1663, #1664).
-
Resolved a segfault in RStudio when rapidly switching between
R and Python chunks in a Quarto document (#1665). -
Improved behavior when the conda binary used to create an environment
cannot be resolved (contributed by @tl-hbk, #1654, #1659). -
Added Positron support for the Variables Pane and
repl_python()
(#1692, #1641, #1648, #1658, #1681, #1687).
reticulate 1.39.0
-
Python background threads can now run in parallel with the R session (#1641).
-
py_main_thread_func()
is deprecated; every R function can now safely be
called from background Python threads (#1648). -
Calls from Python threads into R now notify the main thread using R's native
event loop, ensuring that these calls are handled even when the main thread
is engaged in non-Python tasks (#1648). -
The knitr engine now avoids overwriting Altair's default chart dimensions with
the values ofut.width.px
andut.height.px
. Usealtair.fig.height
,
altair.fig.width
, or Altair'swidth
andheight
parameters to adjust
chart dimensions (contributed by @joelostblom, #1646). -
New
as.character()
method forpython.builtin.str
with support for handling
embedded NULs in strings (#1653). -
New
as.raw()
method forpython.builtin.bytes
(#1649, #1652). -
as.character()
method forpython.builtin.bytes
gains anul
argument,
allowing for convenient handling of embedded NULs in the string (#1652). -
Reticulate now uses the
RETICULATE_VIRTUALENV_ROOT
environment variable when
determining where to resolve virtual environments (#1657). -
conda_run2()
is now exported (contributed by @dramanica, #1637). -
The Python session is now finalized when the R session exits (#1648).
-
Internal updates for NumPy 2.1 (#1651).
-
Fixed error when importing a module named
config
(#1628). -
Fixes for CRAN check failures on macOS-oldrel (#1645).
-
Fixed an error where opening a Python subprocess in Positron on Windows
resulted in "OSError: [WinError 6] The handle is invalid."
(#1658, posit-dev/positron#4457).
reticulate 1.38.0
-
Python Exceptions converted to R conditions are now R lists instead
of R environments, for compatability with {rlang} and {purrr}.
(tidyverse/purrr#1104, r-lib/rlang#1664, #1617) -
Internal updates for NumPy 2.0 (#1621)
-
Added support for converting NumPy StringDType arrays to R character arrays. (#1623)
-
Internal updates for compliance with R's upcoming formalized C API. (#1625)
-
Fixed an issue where attempting to convert a NumPy array with a non-simple
dtype to R would signal an error. (#1613, fixed in #1614).
reticulate 1.37.0
-
Interrupting Python no longer leads to segfaults.
(#1601, fixed in #1602) -
Print method for Python callables now includes the callable’s signature.
(#1605, #1607) -
Reticulate now installs successfully on Windows ARM64.
(#1609, contributed by @andrjohns) -
virtualenv_starter()
no longer warns when encountering broken symlinks.
(#1598) -
Fixed issue where configuration for reticulate
conda_*
functions
to use the executablemamba
instead ofconda
was ignored.
(#1608, contributed by @AlexandreGuinaudeau)
reticulate 1.36.1
-
Fix issue where
py_to_r()
method for Pandas DataFrames would error
ifpy_to_r()
S3 methods were defined for Pandas subtypes,
(as done by {anndata}) (#1591). -
Added an option for extra command-line arguments in
conda_create()
andconda_install()
(#1585). -
Fixed issue where
conda_install()
would ignore user-specified
channels during Python installation (#1594).
reticulate 1.36.0
-
Internal refactoring and optimization now give a faster experience,
especially for workflows that frequently access Python objects from R.
For example, simple attribute access likesys$path
is ~2.5x times faster, and
a sample workload ofpy_to_r(np_array(1:3) + np_array(1:3))
benchmarks
~3.5x faster when compared to the previous CRAN release. -
Fixed issue where callable python objects created with
convert = FALSE
would not be
wrapped in an R function (#1522). -
Fixed issue where
py_to_r()
S3 methods would not be called on arguments supplied to
R functions being called from Python (#1522). -
install_python()
will now build optimized versions of Python on macOS and Linux (#1567) -
Default Python version installed by
install_python()
is now 3.10 (was 3.9) (#1574). -
Output of
reticulate::py_last_error()
now includes a hint, showing how to access
the full R call stack (#1572). -
Fixed an issue where nested
py_capture_output()
calls result in a lost reference
to the originalsys.stdout
andsys.stderr
, resulting in no further visible output
from Python, and eventually, a segfault. (#1564) -
Fixed issues reported by rchk, as requested by CRAN (#1581).
-
py_to_r(x)
now returnsx
unmodified ifx
is not a Python object,
instead of signaling an error. -
New
as.data.frame()
method exported for Python Polars DataFrames (#1568) -
Fixed an issue where printing a delayed module (
import("foo", delay_load = TRUE)
)
would output<pointer: 0x0>
. -
py_validate_xptr()
will now attempt to resolve delayed modules before
signaling an error (#1561). -
R packages can now express multiple preferred Python environments to
search for and use if they exist, by supplying a character vector toimport()
:
import("foo", delay_load = list(environment = c("r-foo", "r-bar")))
(#1559) -
Reticulate will no longer warn about ignored
use_python(,required = FALSE)
calls (#1562). -
reticulate
now prefers using the agg matplotlib backend when the R session
is non-interactive. The backend can also be overridden via theMPLBACKEND
or
RETICULATE_MPLBACKEND
environment variables when necessary (#1556). -
attr(x, "tzone")
attributes are (better) preserved when converting POSIXt to Python.
POSIXt types with a non-emptytzone
attr convert to adatetime.datetime
,
otherwise they convert to NumPydatetime64[ns]
arrays. -
Fixed an issue where calling
py_set_item()
on a subclassed dict would
not invoke a custom__setitem__
method. -
py_del_attr(x, name)
now returnsx
invisibly -
source_python()
no longer exports ther
symbol to the R global environment.
(the "R Interface Object" that is used by Python code get a reference to the
Rglobalenv()
) -
Fixed hang encountered (sometimes) when attempting to call
iterate()
on an exhaustedpy_iterator()
object multiple times (#1539). -
iterate(simplify=TRUE)
rewritten in C for speed improvements (#1539). -
Update for Pandas 2.2 deprecation of
Index.format()
(#1537, #1538). -
Updates for CRAN R-devel (R 4.4) (#1554).
-
Fixed an issue where
py_discover_config()
would discoverpython
(v2) on the PATH
in preference ofpython3
on the PATH. (#1547) -
Fixed an issue where reticulate would error when using conda environments created
with the (new)conda env create
command. (#1535, #1543) -
Fixed an issue where reticulate would error when using a conda environment
where the original conda binary that was used to create the environment
is no longer available (#1555) -
Fixed an issue where a user would be unable to accept the prompt to create
the default "r-reticulate" venv (#1557). -
is_py_object()
is now exported (#1573).
reticulate 1.35.0
-
Subclassed Python list and dict objects are no longer automatically converted
to R vectors. Additionally, the S3 Rclass
attribute for Python objects is
now constructed using the Pythontype(object)
directly, rather than from the
object.__class__
attribute. See #1531 for details and context. -
R external pointers (EXTPTRSXP objects) now round-trip through
py_to_r(r_to_py(x))
successfully.
(reported in #1511, fixed in #1519, contributed by @llaniewski). -
Fixed issue where
virtualenv_create()
would error on Ubuntu 22.04 when
using the system python as a base. (#1495, fixed in #1496). -
Fixed issue where
csc_matrix
objects with unsorted indices could not be
converted to a dgCMatrix. (related to #727, fixed in #1524, contributed by @rcannood). -
Added support for partially unexpanded variables like
$USER
in
XDG_DATA_HOME
and similar (#1513, #1514)
Knitr Python Engine Changes:
-
The knitr python engine now formats captured python exceptions to include the
exception type and any exception notes when chunk options
error = TRUE
is set (reported in #1520, fixed in #1527). -
Fixed an issue where the knitr python engine would fail to include
figures from python chunks if a customroot.dir
chunk option was set.
(reported in #1526, fixed in #1529) -
knitr engine gains the ability to save chunk figures in multiple files/formats
(Contributed by @Rumengol in #1507) -
Fixed an issue where matplotlib figures generated in the initial chunk
where matplotlib was first imported would be the wrong size
(reported in #1523, fixed in #1530) -
Fixed an issue where the knitr engine would not correctly display altair
compound charts if more than one were present in a document (#1500, #1532).
reticulate 1.34.0
v1.34.0 Increment version number to 1.34.0
reticulate 1.32.0
-
reticulate now supports casting R data.frames to Pandas data.frames using nullable
data types, allowing users to preserve NA's from R atomic vectors. This feature is
opt-in and can be enabled by setting the R optionreticulate.pandas_use_nullable_dtypes
toTRUE
. (#1439) -
reticulate now exports a
chooseOpsMethod()
method, allowing for Ops dispatch
to more specialized Ops methods defined for Python objects. -
py_discover_config()
will now warn instead of error upon encountering a
broken Python installation. (#1441, #1459) -
Fixed issue where Python would raise exception "OSError: [WinError 6] The handle is invalid"
when opening a subprocess while running in Rstudio on Windows. (#1448, #518) -
Fixed issue where the multiprocessing Python module would crash or hang when spawning a
Process()
on Windows. (#1430, #1346, fixed in #1461) -
Fixed issue where
virtualenv_create()
would fail to discover a 'virtualenv' module
in the system Python installation on Ubuntu. Reticulate will no longer discover
and attempt to use thevenv
module stub present on Ubuntu systems
where thepython3-venv
apt package has not been installed.
(mlverse/pysparklyr#11, #1437, #1455) -
Fixed issue where the user was prompted to create an 'r-reticulate' venv
in the RStudio IDE before reticulate was requested to initialize Python. (#1450, #1456) -
Improved error message when reticulate attempts to initialize a virtual environment
after the Python installation it was created from is no longer available. (#1149, #1457) -
Improved error message on Fedora when attempting to create a virtual environment
from the system python before runningdnf install python3-pip
. -
Fixed issue where
install_python()
on macOS in the RStudio IDE would fail to discover
and use brew for Python build dependencies. -
Fixed error with
virtualenv_create(python = "/usr/bin/python")
on centos7. (#1467)