Install with pip to Bianca¶
Read through the content below
Installation principle
- Log in to Transit
- (If not done already) Mount the wharf of your project.
- Go to project directory
- Download package
pip download <package name>
- You will get a zip file for each package
- From Bianca session move the file(s) to correct place
- Typical place to put python packages:
~/.local/lib/python<version>/site-packages/
Check for packages¶
- from the Python shell with the
importcommand -
from BASH shell with the
-
pip listcommand - Ex.
ml help python/3.9.5at UPPMAX
Is it not there? Then proceed!
Info
Methods:
- You can just download a python package on Transit with pip, then install from the
.whlfile inwharfon Bianca. - Rackham users: Install it on Rackham. Perhaps you need it here as well! Then transfer to
wharfand Bianca local python library.
Users without access to Rackham/Pelle¶
- NOTE that if you install a package this way, you need to handle any dependencies yourself.
Use transit!
- Log in to transit
- Go to the mounted project folderr
- Load Python of desired version (IMPORTANT!)
- Download with pip
- On Bianca: Load Python of desired version (IMPORTANT!)
- pip install
Transit¶
- Log in to transit:
ssh <username>@transit.uppmax.uu.se - (If not done already) Mount the wharf of your project.
user@transit:~$ mount_wharf sens2025560
Mounting wharf (accessible for you only) to /home/<user>/sens2025560
<user>-sens2025560@bianca-sftp.uppmax.uu.se's password:
- Navigate to your wharf folder
Download on Transit¶
- Load the Python version you plan to use
- Download!
- You should get a
.whlfile
Interested in requirements files etc?
output
console
Usage:
pip download [options] <requirement specifier> [package-index-options] ...
pip download [options] -r <requirements file> [package-index-options] ...
pip download [options] <vcs project url> ...
pip download [options] <local project path> ...
pip download [options] <archive url/path> ...
Installation part on Bianca¶
- Log in to Bianca and the relevant project
- Load the same python version
- Ex.
ml python/3.9.5
- Ex.
pip install --user --no-index --find-links /proj/sens2025560/nobackup/wharf/$USER/$USER-sens2025560 <package-name>==<version>
- NOTE: you don't need the full name of the
.whlfile!
Test it in Python¶
- Start a python console
- Import the package with
import <package> - This should give no errors!
Exercise¶
Install numpy-2.0.0 for Python/3.9.5
Answer
- Using Transit and how to navigate to the porject folder is shown above.
- Load Python:
ml python/3.9.5 - Download
numpy-2.0.0:pip download numpy==2.0.0
How will that look like?
pip download numpy==2.0.0 Collecting numpy==2.0.0 Downloading numpy-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.3 MB) |████████████████████████████████| 19.3 MB 18.5 MB/s Saved ./numpy-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Successfully downloaded numpy
- Resulting file name:
numpy-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
On Bianca:
Rackham users (will not work soon)¶
Rackham¶
Transit set-up¶
- Log in to transit:
ssh <username>@transit.uppmax.uu.se - (If not done already) Mount the wharf of your project.
user@transit:~$ mount_wharf sens2025560
Mounting wharf (accessible for you only) to /home/<user>/sens2025560
<user>-sens2025560@bianca-sftp.uppmax.uu.se's password:
- Navigate to your wharf folder
- Download!
Transfer to the wharf (only if Rackham)¶
If you have not uploaded anything to your wharf, this will be empty. It might have a few things in it.
Now, upload to the wharf the package <package-name> and all the dependency packages pip download got you.
Install on Bianca¶
On Bianca install it (Yes, you can do it from this place) by telling pip where to look for packages and dependencies
- In this case i should have ended up in:
/proj/sens2025560/nobackup/wharf/$USER/$USER-sens2025560
$ ml python
$ pip install --user --no-index --find-links /proj/sens2025560/nobackup/wharf/$USER/$USER-sens2025560 <package-name>
Then the package ends up in ~/.local/lib/python<version>/site-packages/ .
If many files or packages
you may want to tar before copying to include all possible symbolic links:
and in target directory (wharf_mnt) on Bianca:
Isolated/virtual environments¶
Tip
- We HIGHLY recommend using a virtual environment during installation, since this makes it easier to install for different versions of Python.
- However you can also create virtual environments on Bianca from downloaded packages, see above.
Note
Isolated environments solve a couple of problems:
- You can install specific package, also older, versions into them.
- You can create one for each project and no problem if the two projects require different versions.
- You can remove the environment and create a new one, if not needed or with errors.
- More information about isolated environments.
Example, where python packages from the loaded module are used (--system-site-packages)
“projectB” is the name of the virtual environment. The directory “projectB” is created in the present working directory. The -m flag makes sure that you use the libraries from the python version you are using.
- Activate and install with pip (package one by one or from requirements.txt)
- Note that your prompt is changing to start with (analysis) to show that you are within an environment.
- Install the packages from the file::
- Virtual environments can be saved easily anywhere
Transfer to the wharf
If you have not uploaded anything to your wharf, this will be empty. It might have a few things in it.
Move to site-packages folder On Bianca
cd /proj/sens2025560/nobackup/wharf/bjornc/bjornc-sens2025560/
mv –a projectB <path to any place, like project folder>
(Not tested for Transit) Install on Rackham/Transit and then transfer to Bianca
Info
The package ends up on in ~/.local/lib/python<version>/site-packages/ .
- Note that
python<version>is omitting the last number (bug fix), like3.8forpython-3.8.7.
Warning
- If you don't have Rackham, try with Transit and tweak accoring to instruction for the download part above
Install on Rackham/Transit
$ ml python/<version> # this is to make use the correct python version and possible dependencies already available
$ pip install --user <package-name>
- If there is a requirements.txt file with the content of packages to be installed:
Then the package(s) ends up in ~/.local/lib/python<version>/site-packages/ .
Transfer to the wharf
If you have not uploaded anything to your wharf, this will be empty. It might have a few things in it.
- Alt1: If you would like all your locally installed packages:
-
Alt 2: Just transfer the latest installed python package(s)
-
Check what was installed. It may have been several dependency packages as well. Look at the times!
sftp> put -r .local/lib/python<version>/site-packages/<package name 1>
# and if several packages
sftp> put -r .local/lib/python<version>/site-packages/<package name 2>
# and so on...
Move to site-packages folder On Bianca
Error
If problems arise, send an email to support@uppmax.uu.se and we'll help you.