Get Conda

Get mamba which is a faster version of conda from here:

wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh

or just get miniconda:

wget https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Linux-x86_64.sh

Update mamba/conda:

conda update -n base -c conda-forge conda

Init conda:

conda init zsh  # Must restart terminal if running this one.

Create environment

Create environment with env.yml or from scratch:

conda env create -f env.yml -n custom name # notice there is no keyword env
yes | conda create -n repo_name python=python_ver
conda activate repo_name

Or install requirements via pip:

pip install -r requirements.txt

Environment management

conda env list  # list all envs
pip freeze > requirements.txt   # requirements file uses == for versions
conda env remove -n ENV_NAME
conda list torch  # lists only package version

Install packages

Or install packages:

pip install -U numpy pandas matplotlib torchviz scikit-learn tensorboard torchvision torch tqdm torch-lr-finder ipyplot ipywidgets opencv-python
yes | conda install -c conda-forge jupyter_contrib_nbextensions graphviz python-graphviz

to install specific version of a package:

pip install example-package==2.0.1

# Export environment

Alternatively, export environment to a file:
conda env export > env.yml

or if it is cross-platform export simpler no-build number environment:

`conda env export --no-builds | grep -v "prefix" > env.yml`

Jupyter kernels

Add a kernel:

ipython kernel install --name $repo_name --user

Using bash script

  • If making shell file make sure it has correct line endings for the system (for example in PyCharm go to File -> File Properties -> Line Separators)

Make sure the file is executable:

chmod +x utils/setup_new_project.sh check with ls -l
./utils/setup_new_project.sh <repo_name> <python_version>
# for example ./setup_new_project.sh test_repo 3.10

To stop execution after a failure use || exit, for example if the folder doesn’t exist following command will stop the script:

cd $repo_name || exit