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.
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 mechansim. 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 - this version cannot be changed. If you require Python 3, 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.
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¶
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¶
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. Then you will be able to import them in all Python recipes or notebooks within DSS.