🐍 Installation
Windows and Mac users can use [GUI installer](https://docs.conda.io/en/latest/miniconda.html) . Remember to accept adding conda to PATH
Linux or Windows Subsystem Linux (wsl) can do:
# download latest miniconda and install. Remember to accept the license and adding conda to `PATH`
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# Remove the script and activate conda
rm Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
Best Practices:
- 🌱
base
environment ought to be kept as clean as possible - 🌱
jupyter
environment to server a single instance ofjupyter lab
- 🌱 For each project, create a minimal environment
Unless a package is to be used in the global space, e.g. cookiecutter
, and mamba
don't install packages in base. It is the heart of miniconda. The pure it is, the easier is to upgrade and maintain other environments.
Notes: cookiecutter
helps will building project templates while mamba
is a superfast installer
# on base:
conda install --channel conda-forge cookiecutter mamba
create a jupyter
environment to host a single instance of jupyter lab|notebook
. This will be an entry point for other envinroments that require jupyter lab
# creating jupyter env. with python 3.8
mamba create --name jupyter python=3.8 ipykernel jupyterlab ipywidgets nodejs --channel conda-forge
conda activate jupyter
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyterlab-plotly
# adding kernel sharing with a name used to toggle env. on jupyter lab UI
python -m ipykernel install --user --name=jupyter --display-name "Jupyter"
use project name that echoes what the project is about. example of project names. nlp(natural langauge processing) and timeseries
mamba create --name nlp python=3.8 \
ipykernel \
pandas \
scikit-learn \
plotly \
pytorch torchvision torchaudio cudatoolkit=11.1 \
transformers \
--channel pytorch \
--channel huggingface \
--channel plotly
conda activate nlp
python -m ipykernel install --user --name=nlp --display-name "NLP"
conda deactivate
we can select different versions of pythons and use pip install
in the activated environment
mamba create --name timeseries python=3.7 ipykernel pandas scikit-learn plotly --channel plotly
conda activate timeseries
# in activated project environment, you can use `pip install` e.g. `pip install -r requirements.txt`
pip install sktime watermark
python -m ipykernel install --user --name=timeseries --display-name "TimeSeries"
conda deactivate
To use our created environments in Jupyter Lab, activate jupyter environment
and launch jupyter lab in the project folder.
cd documents/stocksanalysis/notebooks
conda activate jupyter
jupyter lab --port 8080
This will serve jupyter lab UI on localhost port 8080. In Jupyter Lab UI, toggle onto the correct environment, e.g. TimeSeries.
🐍 Extras
list available environments
conda env list
remove environment
mamba env remove --name <project_name>
list available kernels
jupyter kernelspec list
remove a kernel project_name
jupyter kernelspec remove <project_name>
export environments
# export
conda activate nlp
conda env export | grep -v "^prefix: " > environment.yml
# import
conda env create -f environment.yml
conda activate nlp
list packages in an envinronment
conda list -n <env_name>
install or uninstall package in an environment
# install httpx from conda-forge channel in timesries environment
mamba install --name timeseries httpx --channel conda-forge
# uninstall pandas from nlp environment
mamba remove --name nlp pandas