How to install Python packages and create Python virtual environments


Installation of Python packages does not require it-support intervention when done correctly.
Installing and managing Python packages and/or virtual environments is users' own responsibility.
When Python package usage asks for Admin rights, that means you are most likely trying to run it in a wrong directory.

Anaconda

JYU uses Anaconda as a general Python distribution. Anaconda includes Conda package and virtual environment manager and PIP Python Install Package manager.

Anaconda can be installed from Software Center.

With Anaconda comes Anaconda Navigator, a graphical desktop application that enables you to use Conda without having to run commands at the command line, and Anaconda Prompt for command line.

Python packages

To install Python packages, you may use PIP or Conda

PIP installation of packages is done by opening Anaconda Prompt and typing

pip install <packagename>

Conda installation of packages is done by opening Anaconda Prompt and typing

conda install <packagename>

Python virtual environments 

To create Python virtual environments you use Conda

Conda allows you to create separate environments, each containing their own files, packages, and package dependencies. The contents of each environment do not interact with each other.

The most basic way to create a new environment is with the following command:

conda create -n <env-name>

To add packages while creating an environment, specify them after the environment name:

conda create -n <env-name> python <packagename>

In JYU Windows computers, the only places you can create environments are

C:\MyTemp

C:\devel\anaconda3\envs

eg. to create a python environment that I decided to name TURF, with python version 3.9.21 into C:\devel\anaconda3\envs you open Anaconda Prompt and type following commands

cd C:\devel\anaconda3\envs
conda create -n TURF python=3.9.21 

Regular Python environments require activation by script

I'll navigate to my virtual environment TURF path in my prompt/shell and run activate.bat  

C:\> \devel\anaconda3\envs\TURF\Scripts\activate.bat 

Easy way to activate your environment with Anaconda Prompt is to give command

conda activate TURF

To return to base Anaconda environment from our virtual environment, type conda activate without environment name

conda activate