2025-01-30
DIY Project | R/Python Project |
---|---|
🏪 Hardware store | Repository (CRAN, PyPI) |
🗄 The storage shelf in your garage | The folder with Python/R libraries |
🧰 Toolboxes (the drill box, the box of screwdrivers) | Packages (ggplot2, etc.) |
🪑 Workbench | Environment: renv , venv |
renv
renv
This creates
renv/
– A new folder that serves as the library of packages for your project..Rprofile
– This file makes sure that once renv
is turned on for a project, it stays on.yields something like
{
"R": {
"Version": "4.4.2",
"Repositories": [
{
"Name": "CRAN",
"URL": "https://cloud.r-project.org"
}
]
},
"Packages": {
"rlang": {
"Package": "rlang",
"Version": "1.1.4",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"utils"
],
"Hash": "3eec01f8b1dee337674b2e34ab1f9bc1"
}
}
}
Source: rstudio.github.io
venv
and pip
Python Environment Hell from XKCD (Creative Commons Attribution-NonCommercial 2.5 License)
pip
is the Python package manager and interacts with PyPI
pip
+ venv
are available by default for Python 3.3+Use the command line: a terminal or from an IDE (VS Code)
What does this do?
venv
to which packages are installed-m
flag calls the main
part of the venv
module)requirements.txt
filesWe can inspect the file
PyPI | conda |
---|---|
Easy to use & create packages | Not only Python, can use external libraries |
Does not track Python version | Tracks Python version |
Complicated with external libraries | Heavy – use miniconda/mamba; packaging is harder |
… And try to keep them apart whenever possible
For R:
For Python:
pip
or conda
, try the other, or try uv