How to install Python packages?

Applies to DSS 2.0 and above | June 07, 2015

DSS has its own Python virtual environment, dedicated to run any Python components of the studio, including any user-installed supplementary packages.

Importantly, this implies that in order to install packages you must NOT use the pip or python commands of your system, but use the pip or python commands of the DSS virtualenv.

There are three kinds of installation:

  1. Python packages installed by pip;
  2. Python packages installed by the python install command;
  3. custom Python packages, that actually do not need to be installed but only copied in the DSS Python libraries folder.

Python packages available on pip

Many python packages can be installed by pip, the python package installer. This is the easiest and recommended way of installing Python packages.

First open a terminal and go to the DSS data directory. To use the DSS pip, you must use the bin/pip command. For instance, to know which Python packages are currently available in DSS you can run the command:

./bin/pip list

And to install a package:

./bin/pip install package_name

If everything went well, you should see at the end of your command:

 Successfully installed package_name
 Cleaning up...

Note that upgrading scikit-learn or pandas is not suported, as DSS relies a lot on it for the machine learning part, and small API changes are likely to break things. We do however upgrade various dependencies of DSS when releasing a new version, after they are properly qualified and we made sure everything works together.

Offline installation

Here is the standard way to install a pip Python package on a server with no internet access. See also the documentation about the format of requirements.txt.

Python packages installed by python

Unfortunately some packages are not available on pip, and usually installing the package requires to run the python install command.

Here’s how you can proceed. First open a terminal and go to the DSS data directory. Finally instead of running python install, run the following command:

./bin/pip install -e package_directory

where package_directory refers to the path to the package directory, which contains the file.

Custom python code

If you have custom python code, for instance a module with user-defined functions and classes, you can copy them in the lib/python subdirectory of the DSS data directory. Then you will be able to import them in all Python recipes or notebooks within the studio.