Installing Python packages¶
Any Python package can be used in DSS. There is no restriction to which package can be installed and used.
The recommend way to install your own Python packages is to install them in a code environment.
Installing in the builtin DSS environment (not recommended)¶
In addition to user-controlled code environments, DSS has its own builtin 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 builtin environment.
Installing packages in the builtin 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 builtin Python environment uses the Python virtualenv mechansim. Importantly, this implies that in order to install packages in the builtin 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 builtin Python environment uses Python 2.7 - this version cannot be changed. If you require Python 3, please use a code environment.
- A number of packages are preinstalled in the builtin 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 builtin 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.
Installing a package available through pip¶
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 on pip
[Many python packages](https://pypi.python.org/pypi) can be installed by [pip](https://pip.pypa.io/en/latest/quickstart.html), 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](/learn/guide/getting-started/dss-concepts/the-dss-datadir.html). 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¶
Here is <a href=”https://pip.pypa.io/en/latest/user_guide/#installing-from-local-packages”>the standard way to install a pip Python package on a server with no internet access</a>. See also <a href=”https://pip.pypa.io/en/latest/reference/pip_install/#requirements-file-format”>the documentation about the format of requirements.txt</a>.
Installing a “python setup.py install” package¶
Unfortunately some packages are not available on pip, and usually installing the package requires to run the python setup.py install command.
Here’s how you can proceed. First open a terminal and go to the [DSS data directory](/learn/guide/getting-started/dss-concepts/the-dss-datadir.html). Finally 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 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](/learn/guide/getting-started/dss-concepts/the-dss-datadir.html). Then you will be able to import them in all Python recipes or notebooks within DSS.