Understanding Python package installation from pip or conda or Linux distro package manager

Conda(including both Anaconda and miniconda) is a well-known Python package manager for machine learning.
This essay compares it with other Python package managers such as pip and apt and then takes down some frequently-used conda commands that might not be directly found on the main tutorials.
Both pip and conda have a good mechanism for installing and upgrading the packages and their indepences, and also vitual running environment like virtualenv and conda env.
I make the preference because conda not only includes all the python packages, but also some other very useful tools that Python uses.

conda install, pip install and sudo install

Generally speaking, conda is superber than pip and ‘apt install’(apt is for Ubuntu, pacman is for Arch Linux, yum is for CentOS…) when handling dozens of virtual running environments. apt install is used for installing python packages for the system because sometimes there are system programs that are based on Python. By the way, it is not recommended to use sudo pip install in a Linux distro with package dependency structures like Arch or Debian due to confliction issues in /usr/local. Rather, one can use pip install --user to install for current user without super-user privilege.
When in a virtual Python environment, you can use pip of this virtual environment to install packages of specific versions independent from those of the OS. Especially in conda virtual environment, both pip and conda are ok. In general, pip is for simple packages or packages that cannot be found in conda. conda install is more ‘intelligent’ because it detects conflicts and removing or upgrading other packages when installing.

To conclude, when you need virtual environment, use conda

when you need to install for current user(which is usually enough), use pip install –user

1
pip2 install --user -i https://pypi.tuna.tsinghua.edu.cn/simple ino

when you need to install system wide, use distro package manager.

1
sudo pacman -S python2-pip

Conda basic commands

To activate this environment(myenv for example), use:

source activate myenv

To deactivate an active environment, use:

source deactivate

To create a version-specified python virtual environment called “vqa” with scipy installed

1
conda create -n vqa python=3.7.1 scipy
几类作图工具的选择 Differences between Python 2.7 and Python 3

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×