Install packages

Install python packages (pip install)

Install pip package manager

# install pip on Ubuntu/Linux command line

sudo apt-get install python-pip

# get latest version of the pip package installer

python -m pip install --upgrade pip

Install package NumPy

# standard system-wide installation

python -m pip install numpy

# alternatively: install local user version

# doesn’t require root admin permissions

pip install --user numpy

# add to your .bashrc file (path to local installation)

export PATH="$PATH:/home/myUserName/.local/bin"

Get installed package version & location (Linux/Ubuntu command line)

pip show numpy

Name: numpy

Version: 1.20.1

Summary: NumPy is the fundamental package for array computing with Python.

Home-page: https://www.numpy.org

Author: Travis E. Oliphant et al.

Author-email: None

License: BSD

Location: /usr/lib/python3.7/site-packages

Requires:

Required-by: scipy, pandas, matplotlib, biopython

Get installed package version & location (within Python)

# start Python

python

# get package version

import numpy

print(numpy.__version__)

1.20.1

import matplotlib

print(matplotlib.__version__)

3.3.4

# get package location

import numpy

print(numpy.__file__)

/usr/lib/python3.7/site-packages/numpy/__init__.py

# compare package versions

# example: check if numpy version is larger than 1.20

# Don't use "LooseVersion": DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.

from packaging import version

version.parse(numpy.__version__) > version.Version('1.20')

True


Read more

https://docs.python.org/3/installing/index.html

https://packaging.pypa.io/en/latest/

http://www.scipy.org/install.html

https://packaging.pypa.io/en/latest/version.html