I have a CentOS 6.4 which the default python version is 2.6.
I want to run a virtualenv at python 2.7, so first I try to install python 2.7.
yum install python27
virtualenv -p /usr/bin/python2.7 ./venv
yum install python-setuptools
yum install python-pip
The second question, how to install pip for python2.7 individually can be solved as the following:
Download python source code of the specific version and install it at /usr/local
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz tar xf Python-2.7.6.tar.xz cd Python-2.7.6 ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" make && make altinstall
Then install setuptools and pip
Install easy_install (prepare ez_setup.py beforehand)
easy_intall-2.7 pip need to visit the internet, in my environment I get the pip source file and use "python2.7 setup.py install".
pip2.7 install [packagename]
In my environment I update .pip/pip.conf to use an internal pip source.
(code above take python 2.7 as an example)
To see the details you can check the following url:
The first question, when creating a new virtual environment, virtualenv will install setuptools for this environment. If python version is not assigned, it use the system default python and default pip. If pip is not find, then try to get it from pypi.python.org.
In my environment, after python2.7 and pip2.7 installed, when trying to create a new virtualenv, it still get pip from pypi.python.org, I guess that virtualenv does not find the relation between python2.7 and pip2.7.
If you can visit pypi.python.org, that is fine.
If you are at an internal environment that can not visit pypi.python.org, virtualenv provides -extra-search-dir and --never-download command. So you can prepare the setuptools beforehand, copy it from U-disk，using scp, or other solutions.
Move setuptools-0.6c11-py2.7.egg to /usr/local/bin.
Finally we can use virtualenv by
virtualenv -p /usr/local/bin/python2.7 --extra-search-dir /usr/local/bin/ --never-download venv