Synapser is a wrapper around the Python client. Due to this, there are some complexities in installing the package. Please follow this guide.
could not find a Python environment for /)When synapser is loaded, it declares its Python requirement
(synapseclient[pandas], pinned to the version synapser
wraps) via reticulate::py_require(). If reticulate does not
find another Python configured on your machine, it uses uv to download a compatible Python
and the Synapse Python client into a managed environment, so you
DO NOT need to install Python yourself. synapser
supports Python 3.10 to 3.14 and does not request a specific one, so
reticulate picks its own default: two minor versions behind the newest
stable release (Python 3.12 as of reticulate 1.46.0). Run
reticulate::py_config() to see which version you got. The
first load may take a minute; later loads reuse the cached
environment.
By default, reticulate only uses this managed environment when no other Python takes precedence in its Order of Discovery. In particular, synapser will use a different Python if any of the following apply:
RETICULATE_PYTHON or
RETICULATE_PYTHON_ENV environment variable is set (this
includes selecting a Python interpreter in RStudio’s Project or Global
Options).VIRTUAL_ENV
is set), or your working directory contains a .venv,
venv, or similar virtual environment.r-reticulate exists (for
example, ~/.virtualenvs/r-reticulate, created by earlier
versions of these instructions).In those cases synapser installs the Synapse Python client into that
Python, which must be version 3.10 to 3.14. To use the managed
environment instead, remove the conflicting setting,
e.g. reticulate::virtualenv_remove("r-reticulate"), and
restart R. You can check which Python synapser is using with
reticulate::py_config().
The synapser source code is on GitHub at Sage-Bionetworks/ synapser. In stalling from GitHub is useful if you want to try changes t hat have not been released to the Synapse R repository (RAN ) yet. For everyday use, install a released version from RA N as shown above.
Install the remotes package if you
don’t already h ave it:
Install synapser from GitHub. Without a
ref, this installs the default branch,
develop, which contains the latest development changes:
Optionally, install a specific branch or release
by passing ref:
Restart R, then load synapser to confirm the install ation:
C:\Program Files\R\R-4.2.0\bin\R.exeOnce that’s complete, we are ready to move on to selecting our desired Python interpreter. If the above fails, follow the steps below, then run the installation.
To select our desired Python interpreter, let’s navigate to Tools > Project Options (or Global Options)
In the example above, we can see that my desired Python 3.9.6 environment (your python version may be different, and that’s ok) installed from the official Python installer and NOT the Python version that shipped on macOS - is selected.
Below are step-by-step instructions for installing synapser using Python 3.10. If you followed the pyenv installation above, these steps will use your pyenv-managed Python. If you’re using a system Python installation, ensure it’s Python 3.10.
If using pyenv (recommended):
# This is a bash session - Not R code
# Verify pyenv is working and Python 3.10 is installed
pyenv versions
python --version # Should show Python 3.10
pyenv versionIf using system Python:
Remove existing reticulate virtual environment (provides a clean environment for installation):
Create a virtual environment using your Python 3.10 installation:
If using pyenv (recommended):
# This will use the pyenv-managed Python 3.10
# You must replace '3.10.x' with the specific version you installed, e.g., '3.10.18'
reticulate::virtualenv_create(envname='r-reticulate', version = '3.10.x')If using system Python 3.10:
Install synapser using remotes (this will automatically handle dependency versions):
For the latest version:
# Install remotes if not already installed
if (!require("remotes", quietly = TRUE)) {
install.packages("remotes")
}
reticulate::use_virtualenv("r-reticulate", required = TRUE)
# Install the latest version of synapser (handles compatible dependency versions automatically)
remotes::install_cran("synapser", repos = c("http://ran.synapse.org", "https://cloud.r-project.org"))For a specific version:
# Install remotes if not already installed
if (!require("remotes", quietly = TRUE)) {
install.packages("remotes")
}
reticulate::use_virtualenv("r-reticulate", required = TRUE)
# Install a specific version of synapser (e.g., version 2.1.1.259 - major.minor.patch.build)
remotes::install_version("synapser", version = "X.Y.Z.AAA", repos = c("http://ran.synapse.org", "https://cloud.r-project.org"))Installing from source:
If you previously pinned rjson or
reticulate for synapser 2.x, undo those pins.
synapser 3.0.0 works with current versions of both, and it requires
reticulate 1.44.0 or later — reticulate 1.28 will break
it:
Then try step 3 again.
~/.virtualenvs/r-reticulate (or Conda if that’s your
preferred Python virtual env) and perform the below step. R-Studio will
re-create a virtual environment at that path using the correct Python
version. Manually specifying python at the official installation path
doesn’t always fix it.~/.virtualenvs/r-reticulate
before re-building (it will be re-created).$HOME\AppData\Local\R\win-library\4.2\00LOCK-synapser)/usr/bin/python3 - but it doesn’t work
well.C:\Users\USER\AppData\Local\Programs\Python\Python310\This step is optional, but recommended if you plan to use multiple Python versions or want full control over your Python environment. Most synapser users do not need pyenv unless they have special requirements. ## Option 1: Using pyenv (Recommended)
We strongly recommend using pyenv to manage Python
versions, as it provides better compatibility and easier version
switching. This is especially important for synapser, which requires
Python 3.10-3.14.
Find more information about pyenv here
For macOS:
# Using Homebrew (recommended)
brew install pyenv
# Or using the automatic installer
curl https://pyenv.run | bashFor Linux (including Ubuntu/Amazon Linux):
# Install dependencies first
sudo apt-get update
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git
# Install pyenv
curl https://pyenv.run | bashFor Amazon Linux 2/RHEL/CentOS:
To make pyenv available permanently, you need to add it to your shell
configuration file. The temporary export command only works
for the current session.
Step 1: Determine your shell
echo $SHELL
# Common outputs:
# /bin/bash -> use ~/.bashrc or ~/.bash_profile
# /bin/zsh -> use ~/.zshrcStep 2: Add pyenv to your shell configuration file
For bash users:
# Add to ~/.bashrc (Linux) or ~/.bash_profile (macOS)
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
# For macOS bash users, also add to ~/.bash_profile
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init --path)"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profileFor zsh users:
# Add to ~/.zshrc
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init --path)"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrcAlternative: Manual editing You can also manually edit the configuration file:
Then add these lines to the file:
Step 3: Apply the changes
# Reload your shell configuration
source ~/.bashrc # for bash on Linux
source ~/.bash_profile # for bash on macOS
source ~/.zshrc # for zsh
# OR restart your terminalStep 4: Verify pyenv is working
# List available Python versions
pyenv install --list | grep " 3\.10"
# Install Python 3.10 (recommended version)
pyenv install 3.10
# Set as global default (optional)
pyenv global 3.10
# Or set as local for your project directory
cd /path/to/your/project
pyenv local 3.10
# Verify installation
python --version # Should show Python 3.10
pyenv versionIf you prefer not to use pyenv, you can install Python from the official installers:
Install Python from one of the official Python installers - version
3.10 to 3.14 and remove other versions of Python except for the one that
ships with macOS located in usr/bin/python (note for
windows: make sure to add Python to path if you’re planning on running
the project from outside RStudio, for example from terminal). TIP: You
can verify which version you have with….
% which -a python3
/usr/bin/python3 # <- Default Python shipped with macOS
% which -a python3
/usr/local/bin/python3 # <- Official Python installer (3.11.1 for me)
/usr/bin/python3 # <- Default Python shipped with macOS
macOS ships with Python by default - Python 3.8 or Python 3.9.6 at the location /usr/bin/python3 - but it doesn’t work well.
Only the official installer versions work. Seriously. Please do yourself a favor and avoid having a very long, sad day because you insisted on using the version that shipped with macOS by default.