Installing Python packages¶
Any Python package can be used in DSS. There is no restriction to which package can be installed and used.
The recommended way to install your own Python packages is to install them in a code environment.
As usual with Python package installation on Linux, you may need to install additional system dependencies if the target Python packages include native code. In particular you may need the system development tools (“build-essentials” on Debian/Ubuntu, “@Development tools” on RedHat/CentOS) and the Python interpreter header files (“python-dev” on Debian/Ubuntu, “python27-devel” on RedHat/CentOS 6.x, “python-devel” on RedHat/CentOS 7.x).
Installing in the built-in DSS environment (not recommended)¶
In addition to user-controlled code environments, DSS has its own built-in Python virtual environment, dedicated to run the system Python components of DSS. It is possible, although not recommended, to install your own packages in that built-in environment.
Installing packages in the built-in environment requires shell access on the host running DSS and can only be performed by DSS administrators.
Please pay attention to the following notes:
- The built-in Python environment uses the Python virtualenv mechanism. Importantly, this implies that in order to install packages in the built-in environment, you must NOT use the pip or python commands of your system, but use the pip or python commands of the DSS virtualenv.
- The built-in Python environment uses Python 2.7 or 3.6, as chosen at installation time. If you require another version of Python,
please use a code environment.
- A number of packages are preinstalled in the built-in environment. Modifying the version of these packages is not supported and may result in causing DSS to stop functioning. Notably, you must not change the version of the
scikit-learnpackages in the built-in environment. We upgrade these dependencies of DSS when releasing a new version, after they are properly qualified and we made sure everything works together.
- The additional Python packages installed by
DATA_DIR/bin/pipor added to
DATA_DIR/lib/pythonare preserved by DSS upgrades.
There are three kinds of installation:
- Python packages installed by pip;
- Python packages installed by the python setup.py install command;
- custom Python packages, that actually do not need to be installed but only copied in the DSS Python libraries folder.
Python packages available through pip¶
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:
cd DATA_DIR ./bin/pip list
And to install a package:
cd DATA_DIR ./bin/pip install package_name
If everything went well, you should see at the end of your command:
Successfully installed package_name Cleaning up...
Installing without Internet access¶
Installing a “python setup.py install” package¶
Some packages are not available through pip, and must be installed from source with the
python setup.py install command.
Here’s how you can proceed in such a case. First open a terminal and go to the DSS data directory.
Then instead of running
python setup.py install, run the following command:
cd DATA_DIR ./bin/pip install -e package_directory
where package_directory refers to the path to the package source directory, which contains the setup.py file.
Installing custom Python packages¶
This will make your custom Python packages globally available for all Python code running with DSS.
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 DSS.