Quick Install Guide

Before you can use PySyft, you will need to get it installed. The documentation features a full deployment guide that covers all the possibilites to install and deploy PySyft on serves, and in production environments.

This section will guide you to a minimal installation that will work while you walk through the introduction, and the Quick start tutorial.

Install Python

Python is first-class citizen in PySyft. Therefore, you need to have Python installed on your computer in order to use PySyft.

PySyft requires Python 3.10+, which means that any version of Python 3.9 or newer is compatible with PySyft. Get the latest version of Python at https://www.python.org/downloads/ or with your operating system’s package manager.

You can verify that Python is installed by typing python from your shell; you should see something like:

Python 3.x.y
[GCC 4.x] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Install PySyft

The PySyft package has a suite of dependencies in order to offer an off-the-shelf data science environment. For this reason, before installing PySyft, it is highly recommended to create a Python virtual environment. in order to isolate the PySyft installation from any other libraries, or data science environments you may already have.

Create a Virtual Environment

There are many ways in which you can create a virtual environment in Python, and any way you may be already using to manage your virtual environments is equally valid and appropriate.

In this guide, we will show how to quickly create a new Python virtual environment using the venv module included in the Python Standard library. Each virtual environment will have their own independent set of Python packages installed in their site directories.

Pre-existent Python installation

The module supports creating lightweight “virtual environments”, that is a virtual environment created on top of an existing Python installation. In other words, you need to have version of Python already installed on your computer in order to create this virtual environment.

To create a new environment, it is necessary to execute the command venv:

$ python -m venv /path/to/new/virtual/environment

Note

The $ symbol in the command is just a placeholder to represent a generic Terminal prompt in Linux/Unix operating systems.

Windows users

If you are using Windows, the above command will not work. The equivalent version of the same command in Windows PowerShell would be:

PS > python -m venv \path\to\new\virtual\environment\

This will create a new folder, where the virtual environment resides. To start using the new virtual environment it is necessary to activate it. We can activate the new environment by executing a shell script that comes with the installation.

$ source /path/to/new/virtual/environment/bin/activate

Once activated, the prompt in your current shell should change by including the name of your environment.

Windows users:

PS > \path\to\new\virtual\environment\Scripts\activate

Once activate, we are good to go and to proceed with the installation of PySyft.


Installing PySyft

Installing PySyft is very simple, and it can be installed using pip:

$ pip install syft

This will download the syft package, along with all its dependencies.

Verify the Installation

To verify that PySyft has been correctly installed, and that it can be found in the path of Python packages, type python from your shell.

Check virtual env

Please make sure that you are still using the previously activate virtual environment, where PySyft has been installed.

Then, at the Python prompt, try to import PySyft:

>>> import syft as sy
>>> print(sy.__version__)
0.9

Updating an existing (older) version of PySyft

If you have an older version of PySyft installed, it is possible to update it to the latest version by running the following command:

$ pip install --upgrade syft

However, in order to be sure that all the satisfied and working, we would always recommend to follow the instructions above to create a fresh new installation of PySyft within a dedicated Python virtual environment.

Quick Note on Code notation

You might have noticed that in the previous import statement when importing syft, we have used an alias (i.e. the as Python keyword).

This is because it is customary in Python common coding practice to use alias to shorten package names, to be used throughout the code. This practice has now become a de-facto standard when importing certain packages so that it is immediately clear to anyone which package we are referring to when reading the code.

This is the case for example of NumPy, or Pandas:

import numpy as np
import pandas as pd

We will use this notation throughout the documentation, using sy as a short for syft.