Using pip
This is the recommended method, assuming user has access to pip.
Check if pip is installed with either:
-
which pip
-
which pip3
Install packages relative to your home directory with either of the following commands:
-
pip install --install-option="--prefix=$HOME/local" package_name
-
pip install --user package_name
Download and Install Anaconda
Anaconda is recommended if users do not have access to pip. If it is already installed, consult the Using Anaconda section below.
1. Check that anaconda isn't already installed with `which conda`.
2. Download the shell script from anaconda's website. To get the latest download url, go to Anaconda's website and right click the download button with the 'copy link' option.
curl --location --output anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
3. Run the installer
bash anaconda.sh
4. Enter through the license and answer 'yes' to all the questions. Specifically when it asks "Do you wish the installer to initialize Anaconda3 by running conda in it?" make sure to say yes.
5. Ensure that anaconda is installing in
/home/<your username>/anaconda
6. Go to your home directory, if you are not already there, and source your `.bashrc` file.
cd ~ source .bashrc
7. Verify your installation
conda info
8. Install pip and any other packages you may want
conda install pip conda install whatever_you_want
Using Anaconda
Create a local anaconda environment:
conda create -n myenv python=3.9
Install to a specific env, with the `-n` flag
conda install -n env-name package-name
See Anaconda's managing environments documentation for how to manage anaconda environments
Using virtual env (venv)
These instructions should be used with venv 3.3 or above only.
Create a virtual environment in your home directory:
python -m venv ~/my-env
Activate the virtual environment:
source ~/my-env/bin/activate
Install your desired packages:
pip install whatever
Using pipenv
Before using pipenv, please read pipenv documentation for a description of what pipenv is and how to install it. Much of its functionality is beyond the scope of this documentation.
Please note: Pipenv is helpful for large projects, where keeping dependencies installed and up-to-date is an issue. If you are working on small projects and/or ones which don't need to be deployed/shared, then pipenv is probably not necessary.
The capability that we are concerned with is installing modules without root. To do this, simply `cd` into your project's directory:
cd your_project_folder
Then install your desired package:
pipenv install package_name