Set up an isolated python environment

2023-10-29

In practial, we may encounter dependecy error when installing python packages through pip command. To address this problem, setting up an isolated and clean environment of python is necessary. After doing some research, I decided to use anaconda to address my problem.

  • install anaconda: sudo pacman -Sy anaconda
Please run
    $ source /opt/anaconda/bin/activate root
    $ source /opt/anaconda/bin/deactivate root
to activate and deactivate the anaconda enviroment.
  • source /opt/anaconda/bin/activate root

  • create isolated environment: conda create -n py3 python=3.11 or conda create -n py2 python2.7

# To activate this environment, use
#
#     $ conda activate pytorch
#
# To deactivate an active environment, use
#
#     $ conda deactivate
  • activate environment: conda activate py3 or conda activate py2

  • show available packages: pip list

  • install packages of specifical version: pip install package-name==version --proxy 127.0.0.1:8118

  • list environment: conda env list

  • remove environment: conda env remove --name <environment_name>

That is it, enjoy your journey of python.