I have a shared account in a web-hosting that has Python 2.4 installed, but my code is not compatible with 2.4. Is it possible to install Python 2.6 directly to Virtualenv?
Note: I don´t have permission to install it in the shared server.
I have a shared account in a web-hosting that has Python 2.4 installed, but my code is not compatible with 2.4. Is it possible to install Python 2.6 directly to Virtualenv?
Note: I don´t have permission to install it in the shared server.
Pre-requisites:
sudo easy_install virtualenv
sudo pip install virtualenvwrapper
Installing virtualenv with Python2.6:
/usr/local
or another location./usr/local
, add it to your PATH.python2.5
andpython2.6
Create a new instance of virtualenv with
python2.6
:mkvirtualenv --python=python2.6 yournewenv
I have not found suitable answer, so here goes my take, which builds upon @toszter answer, but does not use system Python (and you may know, it is not always good idea to install setuptools and virtualenv at system level when dealing with many Python configurations):
The trick of breaking chicken-egg problem here is to make virtualenv without setuptools first, because it otherwise fails (pip can not be found). It may be possible to install pip / wheel directly, but somehow easy_install was the first thing which came to my mind. Also, the script can be improved by factoring out concrete versions.
NB. Using xz in the script.
No, but you can install an isolated Python build (such as ActivePython) under your
$HOME
directory.This approach is the fastest, and doesn't require you to compile Python yourself.
(as a bonus, you also get to use ActiveState's binary package manager)
Now a days, the easiest way I found to have a more updated version of Python is to install it via conda into a conda environment.
Install conda(you may need a virtualenv for this)
Installing a new Python version inside a conda environent
I'm adding this answer here because no manual download is needed.
conda
will do that for you.Now create an environment for the Python version you want. In this example I will use
3.5.2
, because it it the latest version at this time of writing (Aug 2016).Will create a environment for conda to install packages
To activate this environment(I'm assuming linux otherwise check the conda docs):
Now install what you need either via pip or conda in the environemnt(conda has better binary package support).
Although the question specifically describes installing 2.6, I would like to add some importants points to the excellent answers above in case someone comes across this. For the record, my case was that I was trying to install 2.7 on an ubuntu 10.04 box.
First, my motivation towards the methods described in all the answers here is that installing Python from deadsnake's ppa's has been a total failure. So building a local Python is the way to go.
Having tried so, I thought relying to the default installation of pip (with
sudo apt-get install pip
) would be adequate. This unfortunately is wrong. It turned out that I was getting all shorts of nasty issues and eventually not being able to create a virtualenv.Therefore, I highly recommend to install pip locally with
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py && python get-pip.py --user
. This related question gave me this hint.Now if this doesn't work, make sure that
libssl-dev
for Ubuntu oropenssl-dev
for CentOS is installed. Install them withapt-get
oryum
and then re-build Python (no need to remove anything if already installed, do so on top).get-pip
complains about that, you can check so by runningimport ssl
on a py shell.Last, don't forget to declare
.local/bin
and local python to path, check withwhich pip
andwhich python
.This procedure installs Python2.7 anywhere and eliminates any absolute path references within your
env
folder (managed by virtualenv). Even virtualenv isn't installed absolutely.Thus, theoretically, you can drop the top level directory into a tarball, distribute, and run anything configured within the tarball on a machine that doesn't have Python (or any dependencies) installed.
Contact me with any questions. This is just part of an ongoing, larger project I am engineering. Now, for the drop...
Set up environment folders.
Get Python-2.7.3, and virtualenv without any form of root OS installation.
Extract and install Python-2.7.3 into the
pyenv
dir.make clean
is optional if you are doing this a 2nd, 3rd, Nth time...Create your virtualenv
Fix the symlink to python2.7 within
env/include/
Fix the remaining python symlinks in env. You'll have to delete the symbolically linked directories and recreate them, as above. Also, here's the syntax to force in-place symbolic link creation.
Test
Aloha.