Python Virtual Environment in Sandbox
Last updated
Was this helpful?
Last updated
Was this helpful?
Python Virtual Environment is a Python tool for project isolation. It enables the installation of any Python module you like independently from other python modules in Sandbox.
Python Virtual Environment is basically a folder within your IVM that contains all necessary components: site-packages, symlinks, and scripts to execute Python programs using those Python interpreter and site packages installed in Python Virtual Environment.
In addition, the virtual environment enables installation directly to your home directory and automatic environment configuration so that your packages are found from that environment.
See an example of how to install python packages to Sandbox from (at 23min 23sec).
Compared to Python Virtual Environment use the same system as IVM and images cannot be copied from repositories. With Virtual Environments Sandbox users can install packages through /home/ivm
thus needing no request to the service desk (finngen-servicedesk@helsinki.fi). In addition, Virtual Environments are users' personal environments, unlike Docker images which are shared with all Sandbox users.
In this tutorial we will make a Python Virtual Environment for a package we install to python3 (instead of python2, see installation to python2 ). In our example, we use the yhaplo
package.
In Sandbox open Terminal Emulator and go to your home directory
Make a virtual environment named yhaplo_env
Activate virtual environment
The name of your virtual environment will appear indicating you are inside a virtual environment
Unzip dependencies
Move to unziped folders and install six and yhaplo to virtual environment. Note that the code must be run in the package's folder where setup.py exists.
Check the yhaplo
will show
Deativate virtual environment
Check yhaplo again just to compare
will show
The input data is now editable in /home/ivm/yhaplo-master/input/
as required by the package.
Copy dependencies from green bucket. (If the dependencies are not yet in green bucket see instructions )