Conda: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
No edit summary
 
(38 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Conda is a powerful package manager and environment manager. It has a large collection of packages that often are newer than what's installed on your system.
Conda is a powerful package and environment manager. It has a large collection of packages that often are newer than what comes with the operating system.


Conda packages are neatly contained under your home directory in an environment. Adding or removing packages does not require root access or server admin.
Conda packages are neatly contained under your home directory in an environment. Adding or removing packages does not require root access or server administrative privilege.


These Conda environments are most helpful when a package cant be installed globally because it could cause breakage on other users or when you need multiple versions of a package.
These Conda environments are most helpful when a package cannot be installed globally because it could cause breakage for other users, or when you need multiple versions of a package.




== Getting started ==
== Getting started ==


See the Conda guide:
See the "Miniconda quick start guide" below, or the Conda guide:
https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html
https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html


I advise to go with miniconda because it's smaller without a bunch of extras you'll likely never use.
We suggest miniconda over anaconda because it takes a minimalistic approach.


 
== Miniconda quick start guide ==
== Quick start guide ==


Here is a short guide to get you started. Feel free to use a different tag than "mymath".
Here is a short guide to get you started. Feel free to use a different tag than "mymath".
Line 21: Line 20:
# Install
# Install
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh
bash ./Miniconda*
chmod +x Miniconda3-py39_4.10.3-Linux-x86_64.sh
./Miniconda3-py39_4.10.3-Linux-x86_64.sh -b -s -p "$HOME/miniconda3"


# if: during the install you included the .bashrc tweak
# Run the following to have the conda command available on your shell
# then: you can re-login to have the conda command in your path.
source $HOME/miniconda3/etc/profile.d/conda.sh
# else: run the following script to update your PATH
# if using tcsh or csh, run this instead: source $HOME/miniconda3/etc/profile.d/conda.csh
source ~/miniconda3/etc/profile.d/conda.sh


# now you can use the conda command. It's advised to create a enviornemnnt and then switch to it
# HINT: you can add the source script to ~/.bashrc or ~/.cshrc so conda is available on next login.
 
# Create an environment. You can do this for each project or make a generic one to reuse
conda create --name mymath
conda create --name mymath
# Activate the environment
conda activate mymath
conda activate mymath
# In your "mymath" enviornemnnt you can confirm its using it's python using `which python`


# Feel free to install pacakges. For example:
# Examples installing packages into the conda environment:
conda install openblas gcc_linux-64
# HINT: try and install everything in one line so conda can resolve dependencies.
conda install python scipy numpy imageio ipython matplotlib
conda install mkl gcc_linux-64
conda install mkl gcc_linux-64
conda install scipy numpy imageio ipython matplotlib
# pip also works smoothly with the environment
pip install requests
 
# Check we are using our personal python binary
which python
> /home/myuser/miniconda3/envs/mymath/bin/python


# ...after log out: to return to your python enviornemnnt use:
# Unlink the current conda environment and check which python is selected
source ~/miniconda3/etc/profile.d/conda.sh
conda deactivate
conda activate mymath
which python
> /usr/bin/python
 
# After a fresh log in, do the following to return to your environment:
source $HOME/miniconda3/etc/profile.d/conda.sh # or conda.csh
conda activate myenvname
</pre>
</pre>

Latest revision as of 15:05, 7 January 2022

Conda is a powerful package and environment manager. It has a large collection of packages that often are newer than what comes with the operating system.

Conda packages are neatly contained under your home directory in an environment. Adding or removing packages does not require root access or server administrative privilege.

These Conda environments are most helpful when a package cannot be installed globally because it could cause breakage for other users, or when you need multiple versions of a package.


Getting started

See the "Miniconda quick start guide" below, or the Conda guide: https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html

We suggest miniconda over anaconda because it takes a minimalistic approach.

Miniconda quick start guide

Here is a short guide to get you started. Feel free to use a different tag than "mymath".

# Install
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh
chmod +x Miniconda3-py39_4.10.3-Linux-x86_64.sh
./Miniconda3-py39_4.10.3-Linux-x86_64.sh -b -s -p "$HOME/miniconda3"

# Run the following to have the conda command available on your shell
source $HOME/miniconda3/etc/profile.d/conda.sh
# if using tcsh or csh, run this instead: source $HOME/miniconda3/etc/profile.d/conda.csh

# HINT: you can add the source script to ~/.bashrc or ~/.cshrc so conda is available on next login.

# Create an environment. You can do this for each project or make a generic one to reuse
conda create --name mymath

# Activate the environment
conda activate mymath

# Examples installing packages into the conda environment:
# HINT: try and install everything in one line so conda can resolve dependencies.
conda install python scipy numpy imageio ipython matplotlib
conda install mkl gcc_linux-64
# pip also works smoothly with the environment
pip install requests

# Check we are using our personal python binary
which python
> /home/myuser/miniconda3/envs/mymath/bin/python

# Unlink the current conda environment and check which python is selected
conda deactivate
which python
> /usr/bin/python

# After a fresh log in, do the following to return to your environment:
source $HOME/miniconda3/etc/profile.d/conda.sh  # or conda.csh
conda activate myenvname