The right way for ArchLinux
The right way to install PYTHON packages in ArchLinux is using PACMAN! To install packages to Python3 you have to use
sudo pacman -S python-'package'
If you want to install packages from Python2, you have to use
sudo pacman -S python2-'package'
Most python packages are in the ArchLinux repositories and the packages that are not in AUR (ArchLinux User Repositories) - for these packages you have to download the PKGBUILD file and compile. After that, you have to use PACMAN to finish the installation
makepkg -s
sudo pacman -U 'compiled-package'
The second right way for ArchLinux
When the package isn't in the AUR or the PKGBUILD isn't working, you can use PIP to install it to Python3
sudo pip install 'python-package'
or Python2
sudo pip2 install 'python-package'
BE AWARE: when you are using pip
the same installation folder is shared with pacman
and most of time, especially when you are updating all system packages (sudo pacman -Suy
), will raise a conflict error. You always have to prefer the first option above.To solve conflict problems, just uninstall pip
package and install they equivalent package on pacman
(pip uninstall 'python-package'
).
You could give a chance to virtualenv
or even conda
If you are planning to develop some python application or python package your better option is use virtual environments.
For python packaging applications you should try poetry
it is current better option to manage application from start to finish. It is a much better option than requirements.txt
+ setup.py
.
Another more simple option is use python-virtualenv
. This can bring portability to your code and maintain old packages as well. Install it with
sudo pacman -S python-virtualenv
and try this
virtualenv -p /usr/bin/python3 yourenv
source yourenv/bin/activate
pip install package-name
When you create this environment yourenv
, you will setup pip
to install packages only into this environment, not to the entire system.
These other links can be useful with you want to learn more about managing packages on Linux with conda
or virtualenv
:
Installing Python Packages from a Jupyter Notebook
If you follow these rules, your ArchLinux will not break and won't have dependency problems between PACMAN and PIP.
Hope it's useful!
python
and wish I'd known this beforesudio
pip-ping things. Thanks for this. – Hendy Jan 14 '17 at 17:06/opt
. if a package does not work if installed in/opt
then it most likely has hardcoded paths which i consider a bug. – Lesmana Oct 07 '19 at 19:50