How to install a Python package into Sandbox
Follow the instructions here to load your package into FinnGen green bucket. After your package is in the green bucket follow these steps to install the Python package to your home/ivm.
If you have third-party packages and many dependencies installation from the source may get tricky. You may consider using the Anaconda Python environment within a Docker image instead.
Step 1:
In sandbox open Terminal Emulator. Check that you are in /home/ivm
Step 2:
Copy the source code from /finngen/green to /home/ivm/. Here we will load source code for yhaplo software.
Step 3:
Extract the source code
Step 4:
Change directory
Step 5:
Check the status of installation in sandbox environment
Step 6:
Information about the package appear indicating that the package is installed on python2.
To uninstal Python package
Step 7:
Check the status on python3
Step 8:
No output appears indicating that the package is not installed on python3.
To install the Python package with python3 move to the folder where your package is (here /home/ivm/yhaplo-master).
Step 9:
Install with python3. Note that the code must be run in the package's folder where setup.py exists (here /home/ivm/yhaplo-master).
Step 10:
Check where the package is installed
Step 11:
You have to add the local installed package directory into PYTHONPATH.
There are two ways to do this:
First way is to use command line (This command needs to be run every time you open Sandbox instance)
export PYTHONPATH = $PYTHONPATH:/home/ivm/.local/lib/python3.7/site-packages
Or paste the same command into ~/.bashrc
export PYTHONPATH = "${PYTHONPATH}:/home/ivm/.local/lib/python3.7/site-packages"
and then source the file by typing the below command:
source ~/.bashrc
This way, every Sandbox instance will automatically add the PYTHONPATH
Second way is to add them in Python itself. Doing this one time is enough and it will remember the path next time you run Python or even open a new Sandbox instance. Follow the instruction below:
python3
import sys
sys.path.insert(0,'/home/ivm/.local/lib/python3.7/site-packages')
import yhalpo
Either of them will add the path and will load the installed packages.
Note: If the package is not installed it might be incompatible with other Python packages in the Sandbox. In that case, you can make Python Virtual Environment and load your package there.
Last updated