Synapser is a wrapper around the Python client. Due to this, there are some complexities in installing the package. Please follow this guide.

Install Python and R

If you are not familiar with Python at all, this section is for you, but if you are familiar with setting up your Python environment, you can skip the first step.

  1. Install Python from one of the official Python installers - any version above 3.8 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.

  2. Install R > v4.2.2

    1. Download links
      1. For macOS users, you can select a mirror and download R here
      2. For Windows and Linux users, you can select a mirror and download R here NOTE: There might be an issue installing v4.0.0; please use v4.2.2+ for the best experience
  3. Install RStudio Desktop

  4. For Windows users, if you intend to run the project from outside RStudio Desktop (for example: VS Code or Terminal) the only additional step is to add R to system path: C:\Program Files\R\R-4.2.2\bin\R.exe

Troubleshooting

  • If you get an error while building the project that it cannot find synapseclient module. This is because RStudio is using the wrong python version. To get RStudio Desktop to build the package correctly, navigate to Tools > Project Options > Python > Virtual Envs and select the first entry ~/.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.
  • If you have already tried building the project with an older version of Python, make sure to remove ~/.virtualenvs/r-reticulate before re-building (it will be re-created).
  • If you halt the build process, a lock file might be left behind, which will need to be manually deleted ($HOME\AppData\Local\R\win-library\4.2\00LOCK-synapser)
  • 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.
  • If you’re intending to run the project from terminal or VSCode on Windows and forgot to add python to path, it can be added manually using system environment variables: C:\Users\USER\AppData\Local\Programs\Python\Python310\

Synapse Installation

  • This guide assumes you have Python, R, and RStudio Desktop installed as described above.
  • This guide will presume most users want to install and work with Synapse from RStudio Desktop.

Install from RStudio

install.packages("synapser", repos = c("http://ran.synapse.org", "http://cran.fhcrc.org"))

Once 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.

  1. Select your project’s desired Python interpreter

To select our desired Python interpreter, let’s navigate to Tools > Project Options (or Global Options)

  1. Let’s select Python from the list of options on the left hand side:

  1. Click Select

  1. Select the Virtual Environments tab:

  1. Click on Select to choose our desired Reticulate virtual environment:

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.