You have several options:
virtualenv
Install in virtualenv (assuming the virtualenv
command is installed):
$ cd projectdir $ virtualenv venv $ source venv/bin/activate (venv)$ pip install cryptography (venv)$ vim mycode.py (venv)$ python mycode.py
The trick is that you install in a local virtual environment that does not require root privileges.
toxicodendron
tox
is a great tool. After a little investment, you can easily create several virtualenvs.
It is assumed that tox
installed on your system.
$ tox-quickstart $ ...accept all defaults $ vim tox.ini
It seems to me that tox.ini looks like this:
[tox] envlist = py27 skipsdist = true [testenv] commands = python --version deps = cryptography
then execute (with disabling virtualenvs):
$ tox
it will create virtualenv in the .tox/py27
Activate it (still in the same directory):
$ source .tox/py27/bin/activate (py27)$ pip freeze cryptography==1.2.2 ... and few more...
Install -ser python in profile
Although it allows you to install without root privileges, it is not recommended that it ends soon with one big mess.
EDIT (reaction to MattDMo's comment):
If one user has two projects with conflicting requirements (for example, different versions of the package), installing --user
will not work, because packages living in the same area are divided in all user projects.
With virtualenvs, you can save virtualenv inside project folders and feel free to destroy and recreate or modify any of them without affecting any other project.
Virtualenvs has no "accumulation" problems: if you can find your project folder, you can find and manage the virtual virtual machines associated with it.
Using virtualenv has become the de facto recommended standard. I remember numerous examples starting with the creation of virtualenv, but I cannot recall one case using $ pip install --user
.