GeekEast / anaconda-guides

Guides on how to install/uninstall Anaconda with Python as well as how to manage environments by conda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table Of Content

# Step 1 anaconda clean
conda install anaconda-clean && anaconda-clean

# Step 2 clean files
rm -rf ~/.anaconda_backup && rm /Applications/Anaconda-Navigator.app && rm -rf ~/anaconda
rm -rf ~/.condarc ~/.conda ~/.continuum

# Step 3 remove anaconda from path
code ~/.bash_profile # remove anything related to anaconda, conda then save
source ~/.bash_profile
bash <64-Bit Command Line Installer>

Env Shorthand Config

conda config --set env_prompt '({name})'

Set no base env by default

conda config --set auto_activate_base False

Create an env in current foler

conda create -p ./conda-env anaconda # create anaconda  env
conda create -p ./conda-env python=3.7 # create python 3.7 env
conda create -p ./conda-env anaconda python=3.7 # create anaconda with python 3.7

Activate current folder's env

conda activate ./conda-env

Export current folder's env as yml file

conda env export > environment.yml

Install, Update, Remove and List Packages

conda install pandas
conda install --channel conda-forge <package_name> # from sepcific channel
conda update pandas
conda remove pandas
conda list

Deactivate current folder's env

conda deactivate

Config env from yml file

conda env create -f environment.yml

Baby Usage

  • create native python
conda create --name conda-env python
conda create --name conda-env python=3.7
conda create --name conda-env python=3.7 numpy requests
  • create anaconda env
# create an env called conda-env based on anaconda and python3.7
conda create --name conda-env anaconda python=3.7
# list all conda envs
conda env list
# activate conda-env env
conda activate conda-env
# install pandas in current env
conda install pandas
# update pandas in current env
conda update pandas
# remove pandas in current env
conda remove pandas
# list all packages in current env
conda list
# quit current env
conda deactivate

Anaconda

  • Add jupyter notebook to path in Ubuntu
export PATH=~/anaconda3/bin:$PATH

Create Remote Jupyter Notebook on Server

Generate config

jupyter notebook --generate-config
nano ~/.jupyter/jupyter_notebook_config.py

Modify config

# more than below
c.NotebookApp.open_browser = False
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.password = '<Your_Password>'
c.NotebookApp.token = '' # don't require

Launch and enjoy

nohup jupyter notebook

Examples

Install spacy in conda-env

conda activate ./conda-env
pip install spacy # sometimes use pip
python -m spacy download en

References

About

Guides on how to install/uninstall Anaconda with Python as well as how to manage environments by conda