What is the official preferred way to install pip and virtualenv systemwide?
If you can install the latest Python (2.7.9 and up) Pip is now bundled with it.
See: https://docs.python.org/2.7//installing/index.html
If not :
Update (from the release notes):
I now run the regular:Beginning with v1.5.1, pip does not require setuptools prior to running get-pip.py. Additionally, if setuptools (or distribute) is not already installed, get-pip.py will install setuptools for you.
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python
Here are the official installation instructions:http://pip.readthedocs.org/en/latest/installing.html#install-pip
EDIT 25-Jul-2013:
Changed URL for setuptools install.
EDIT 10-Feb-2014:
Removed setuptools install (thanks @Ciantic)
EDIT 26-Jun-2014:
Updated URL again (thanks @LarsH)
EDIT 1-Mar-2015:
Pip is now bundled with Python
Install pip and virtualenv, a chicken and the egg dilemma?
tl;dr Answer would be VirtualEnv first.
You can have two of them each for Python version 2.x and 3.x
[edit]
I am really doubtful if installing (there is no install, you merely download and execute a script) VirtualEnv system wide/per-user even matters. The whole point of Using VirtualEnv is to create isolated development sandboxes so that the libraries from one project doesn't conflict with each other. For example you can a Python 2.x project using Beautiful-soup Version < 4.x and A Python 3.x project Using Beautiful-soup Version 4.0 in two different Virtual Environments.
How you get VirtualEnv script on your system doesn't really matter, and since once you have it and pip is self contained within VirtualEnv, it just makes sense to get VirtualEnv first. Also once you are in with python, you would have many projects, and for each, the recommended way would be to have a Virtual Environment, and then install dependencies via pip. You can later do "pip freeze > requirements.txt" and then a "pip install requirements.txt" to simply replicate your exact libraries across two systems [say dev and production] and so on...
Install a python package for all users without messing with the system python installation
No, you can never be too afraid of modifying the system Python. Your caution is justified.
I’d suggest you let all users share a global (but non-system) Python installation, either from the official distribution, Anaconda, pyenv’s python-build, or self-compiled source. Each user can then either perform their own pip install --user
to their respective home directories, or you can, as an sudoer, install tools globally available to them, into the custom-managed, non-system, but global Python.
Edit: I forgot to mention that you may also do this with virtual environments and symlinks. An example for Pipenv (you can change paths as you prefer):
python3 -m venv /opt/venvs/pipenv
/opt/venvs/pipenv/bin/pip install pipenv
ln -s /opt/venvs/pipenv/bin/pipenv /opt/bin/pipenv
python3 -m venv /opt/venvs/flake8
/opt/venvs/pipenv/bin/pip install flake8
ln -s /opt/venvs/pipenv/bin/flake8 /opt/bin/flake8
This way to can install multiple tools without them affecting each other. Also you can combine this with custom-managed Python for even more peace of mind. How to install virtualenv without using sudo?
This solution is suitable in cases where no virtualenv
is available system wide and you can not become root to install virtualenv
. When I set up a debian for python development or deployment I always apt-get install python-virtualenv
. It is more convenient to have it around than to do the bootstrap pointed out below. But without root power it may be the the way to go:
There is a bootstrap mechanism that should get you going.
Read: http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python
In essence you would do this in your home directory in a unix environment:
Given your python is version 2.6
There may be room for optimization. I don't like the
$ mkdir ~/bin
$ mkdir -p ~/lib/python2.6
$ mkdir -p ~/local/lib/python2.6/dist-packages
$ wget http://peak.telecommunity.com/dist/virtual-python.py
$ python virtual-python.py --no-site-packages
$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ ~/bin/python ez_setup.py
$ ~/local/bin/easy_install virtualenv
$ ~/local/bin/virtualenv --no-site-packages thereyouare
local
path. Just bin
and lib
would be nice. But it does its job. Installing pip using python interpreter
to get easy_install
, you want to install setuptools
for windows using the executable installer provided here:
http://pypi.python.org/pypi/setuptools
for example, if you are running Python 2.7 on 32-bit windows, the installer would be:setuptools-0.6c11.win32-py2.7.exe
.
This will install setuptools
, which places easy_install.exe
in your C:\Python27\Scripts
directory.
after it is installed, you could install pip (or any package from PyPI), like this:
C:\Python27\Scripts\easy_install pip
Which is the preferred way of installing up to date versions of Python using Powershell? Packaged binaries or online install?
I prefer this solution as it decreases the size of the program overall by not preincluding python.
although its up to your user. if its a library aimed at extending python for other developers, than no need to include the binaries.
instead if this is meant to be standalone, it may be worth it to include the binaries.
although I still prefer what you have so it installs the most up to date version.
How to install a module for all users with pip on linux?
You might have a wrong umask
set as discussed here
From your last edit, I guess you umask
is set to 027
. Try to do
sudo pip uninstall loremipsum
umask 022
sudo pip install loremipsum
Related Topics
Why Use Sys.Path.Append(Path) Instead of Sys.Path.Insert(1, Path)
Get the String Within Brackets in Python
Importing Class from Another File
First Python List Index Greater Than X
Running a Command as a Super User from a Python Script
Is There a Library Function for Root Mean Square Error (Rmse) in Python
Changing Image Hue with Python Pil
Import Text to Pandas with Multiple Delimiters
How to Get Millisecond and Microsecond-Resolution Timestamps in Python
How to Concatenate Element-Wise Two Lists in Python
Where Do the Python Unit Tests Go
How to Print a Dictionary Line by Line in Python
Reading Tar File Contents Without Untarring It, in Python Script
How to Define a Class Constant Inside an Enum
Break the Function After Certain Time
How to Get Windows' Special Folders for Currently Logged-In User