library('reticulate')
py_discover_config()
py_config()
conda_list()
conda_version()
conda_create('sbloggel')
conda_install('sbloggel', 'pandas')
miniconda_update()
use_condaenv('sbloggel')
conda_install('sbloggel', 'plotly')
use_condaenv('base')
Managing python versions in RStudio
Ressources
Managing python installation
Install virtual environments to jupyter
# Prepare python to enable installation of virtual environments in Jupyter:
pip install --user ipykernel
# Show conda environments and activate:
conda info --envs
conda activate sbloggel
# Install virtual environment into jupyter:
python -m ipykernel install --user --name=sbloggel
conda activate /Users/seb/Library/r-miniconda-arm64/envs/sbloggel
Start Jupyter from terminal:
jupyter notebook
Installing tensorflow_decision_forests
- I couldn’t install it via conda, so I created a new environment and installed it via pip (this seems also to be the recommended way on the tensorflow website):
library('reticulate')
conda_create('tensorflow', python_version = '3.11')
use_condaenv('tensorflow')
conda_install('tensorflow', c('tensorflow', 'tensorflow_decision_forests'), pip = TRUE)
conda_install('tensorflow', c('pandas', 'matplotlib', 'seaborn'), pip = TRUE)
conda_install('tensorflow', 'IPython', pip = TRUE)
py_version()
Installing environment - rebuild sbloggel
library('reticulate')
conda_create('sbloggel', python_version = '3.11')
<- c('pandas', 'matplotlib', 'seaborn', 'plotly', 'statsmodels', 'scipy', 'scikit-learn', 'pytorch', 'torchvision')
packages_to_install conda_install('sbloggel', packages_to_install)
use_condaenv('sbloggel')
py_version()
10 + 10
import pandas as pd
import fastai as fa
import torch
= (
device "cuda"
if torch.cuda.is_available()
else "mps"
if torch.backends.mps.is_available()
else "cpu"
)print(f"Using {device} device")