You can use python venv
like described here.
However if you really want to install packages that way, then there are couple solutions:
- remove file
/usr/lib/python3.x/EXTERNALLY-MANAGED
, - use
pip
‘s argument--break-system-packages
, - add following lines to
~/.config/pip/pip.conf
:
[global]
break-system-packages = true