Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Miniconda does ship with a default version of Python.

Code Block
[salexan5@mblog1 conda]$ cd /project/arcc<project-name>/salexan5<username>/conda
[salexan5@mblog1 conda]$ module purge
[]$ module load miniconda3/24.3.0
[salexan5@mblog1 conda]$ conda create -p py_env
## Package Plan ##
  environment location: /cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env

# To activate this environment, use
#     $ conda activate /cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env

[salexan5@mblog1 conda]$ conda activate /cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env

(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ python --version
Python 3.12.2

(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ which python
/apps/u/opt/linux/miniconda3/24.3.0/bin/python

...

Try Installing numpy into our Conda environment

Code Block
([]$ module purge
[]$ module load miniconda3/24.3.0
[]$ conda activate /cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ 
(/cluster/medbow/project/<project-name>/<username>/conda/py_env) []$ pip install numpy
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in /home/salexan5<username>/.local/lib/python3.12/site-packages (1.26.4)

(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ python ~/py_test.py
Python: 3.12.2 | packaged by Anaconda, Inc. | (main, Feb 27 2024, 17:35:02) [GCC 11.2.0]
Numpy: 1.26.4

...

Code Block
# This list should be empty since we have essentially a blank conda environment
# since we have not conda installed anything.
(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ conda list
# packages in environment at /cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env:
#
# Name                    Version                   Build  Channel

...

Code Block
(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ pip list -v
Package                 Version     Location                                                         Installer
----------------------- ----------- ---------------------------------------------------------------- ---------
anaconda-anon-usage     0.4.4       /apps/u/opt/linux/miniconda3/24.3.0/lib/python3.12/site-packages conda
archspec                0.2.3       /apps/u/opt/linux/miniconda3/24.3.0/lib/python3.12/site-packages conda
...
numpy                   1.26.4      /home/salexan5<username>/.local/lib/python3.12/site-packages               pip
...
pip                     23.3.1      /apps/u/opt/linux/miniconda3/24.3.0/lib/python3.12/site-packages
...

...

Code Block
(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]]$ pip install numpy==2.0.0
Defaulting to user installation because normal site-packages is not writeable
...
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.26.4
    Uninstalling numpy-1.26.4:
      Successfully uninstalled numpy-1.26.4
Successfully installed numpy-2.0.0
(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ pip list -v
Package                 Version     Location                                                         Installer
----------------------- ----------- ---------------------------------------------------------------- ---------
...
numpy                   2.0.0       /home/salexan5<username>/.local/lib/python3.12/site-packages               pip
...
Note

The numpy package has been updated, but still lives under: ~/.local/lib/python3.12/

...

Code Block
(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ echo $CONDA_PREFIX
/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env

(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env_3.12.4) [salexan5@mblog2 conda]$ export PYTHONUSERBASE=$CONDA_PREFIX

(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ pip list -v
Package                 Version  Location                                                                        Installer
----------------------- -------- ------------------------------------------------------------------------------- ---------
...
numpy                   2.0.0    /cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env/lib/python3.12/site-packages pip
...

...

Code Block
(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ pwd
/project/arcc<project-name>/salexan5<username>/conda

(/cluster/medbow/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog1 conda]$ ls py_env/lib/python3.12/site-packages/
numpy  numpy-2.0.0.dist-info  numpy.libs

...

Note

Starting a new session, notice which version of numpy is being used by our conda environment before and after setting our PYTHONUSERBASE environment variable.

Code Block
[salexan5@mblog2 ~]$ module purge
[]$ module load miniconda3/24.3.0
[salexan5@mblog2 ~]$ conda activate /project/arcc<project-name>/salexan5<username>/conda/py_env
(/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog2 ~]$ pip list -v
Package                 Version     Location                                                         Installer
----------------------- ----------- ---------------------------------------------------------------- ---------
...
numpy                   2.0.0       /home/salexan5<username>/.local/lib/python3.12/site-packages               pip
...

(/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog2 ~]$ export PYTHONUSERBASE=$CONDA_PREFIX
(/project/arcc<project-name>/salexan5<username>/conda/py_env) [salexan5@mblog2 ~]$ pip list -v
Package                 Version  Location                                                         Installer
----------------------- -------- ---------------------------------------------------------------- ---------
...
numpy                   2.0.0    /project/arcc<project-name>/salexan5<username>/conda/py_env/lib/python3.12/site-packages pip
...

...

Remember: Conda Environments, Pip Installs and Package Locations

Info

Remember: If you do not set export PYTHONUSERBASE=$CONDA_PREFIX (after the Conda environment has been activated), then pip install will place Python packages under ~/.local/lib/pythonX.Y/site-packages.

...