I know that building software from source on my system using root privileges usually causes various problems and that the preferred way to install anything is to use a packet management system (apt-get first, dpkg second).
However, I need some python programs which can be only installed with pip. I have tried to use pip install --install-option="--prefix=/apps/"
, but it seems that also in that case the pip wants to write to /lib/python2.7/
which is a system folder.
Is there a way to install software with pip without the possibility of damaging or polluting my system with unmanaged files?
Best Answer
Python virtual environment creator (python-virtualenv) allows you to create a sandboxed and isolated environment where Python packages can be installed without interfering with other packages on the same machine. With several virtualenvs, many different pieces of Python software with different and even mutually exclusive dependencies can coexist together. You can install python-virtualenv from the default Ubuntu repositories in all currently supported versions of Ubuntu.
Set up a virtual environment for Python anywhere in your home directory, activate your Python virtual environment from the terminal, and then install whatever packages you need to be installed by pip locally in your virtual environment as a normal user using
pip install
.Install Python virtual environment creator (virtualenv):
Make a new directory (I'll call it PythonVirtualEnv in this example) for the Python virtual environment and setup the Python virtual environment with Python and pip in it.
Deactivate the Python virtual environment before leaving it.
Creating an environment with a custom Python interpreter