Reputation: 1337
I am trying to install the latest (2.7.6) version of python on my ubuntu box that already has 2.7.4 installed through the package manager. I'm up for any solution that someone has for this, but am not quite sure how to do this myself.
I have used virtualenv to create virtual python setups for different django versions, but I don't know how to use virtualenv to create an environment with an updated python version (or if it is even possible).
So to install I downloaded the source and created a custom install using the below code
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar -xvf Python-2.7.6.tgz
cd Python-2.7.6
./configure PREFIX=$SOMEBASE/python-2.7.6
make install DESTDIR=$SOMEBASE/python-2.7.6
This seems to work for the installation, however when trying to install a package on python I get the error that it can't write to /usr/local/lib/python2.7/site-packages. I could have it write there by running as root, but wasn't sure what that would do to my existing installation and really, really don't want to break what is already there. So I would love to know if there is a way (and how) I could specify a location for the site-packages to be used (like $SOMEBASE/python-2.7.6/Lib/site-packages).
Upvotes: 0
Views: 3045
Reputation: 880289
Lennart Regebro has written instructions on how to install easy_install, virtualenv, and pip for a particular Python installation.
Alternatively, there is a shell tool called virtualenvwrapper which can automate much of the process. After installing python2.7.6, (and virtualenvwrapper), you'd type
cd ~/.virtualenvs
mkvirtualenv myenv -p /path/to/python2.7.6
to make a new environment called myenv
. mkvirtualenv
will install easy_install
and pip
for you. Once you activate myenv
with
workon myenv
additional modules or packages which you install with easy_install
or pip
will use the right version of Python and will install the modules in ~/.virtualenvs/myenv/lib/python2.7/site-packages
.
Upvotes: 1
Reputation: 172309
Normally you rn and build Python like this:
./configure --prefix=/wherever/python-2.7.6
make
sudo make install
You'll still have to sudo when installing modules, but that's good, prevents you from doing it by mistake. They will be installed to /wherever/python-2.7.6/lib/python2.7/site-packages
.
Upvotes: 1