After several trials and tribulations, I finally managed to get an independent Python 2.6.1 version running smoothly on Ubuntu 8.10 (“Intrepid”), without interfering with the system’s reliance on Python 2.5 and without breaking the entire package dependency system. The procedure described here has been successfully carried out on the Easy Peasy distribution of Ubuntu (ex-”Ubuntu-eee”), specifically tailored for the Asus EEE-PC. It should work, though, with any other 8.10 version of Ubuntu. It has also been tested successfully on Ubuntu 8.04 (“Hardy”).
A lot of the following information will be obvious to people with a thorough knowledge of both Linux and Python. However, coming from Mac OSX, things haven’t been that obvious. For the poor souls who will be frantically googling for “zlib”, “zipimport.ZipImportError”, “setuptools”, “ipython”, “readline” and “ubuntu”, I offer a series of steps which, so far, haven’t disturbed the operating system and allow one to run the essential IPython environment (and a lot more) without pulling one’s hair out. It’s actually quick and easy and involves no hacking whatsoever (I wouldn’t know how to hack either Python or Linux anyhow).
DISCLAIMER: My knowledge of linux is superficial. I write the following with the intent of helping out newbies such as myself. Do not hold me reponsible if you follow my method and end up with a system that’s pushing up the daisies.
NOTE: This method has been tested on GNOME, the default desktop environment for my distribution. I haven’t tried it with KDE and, now that it’s finally working, I don’t think I will.
ACKNOWLEDGEMENT: I would never have gotten Python 2.6.1 and Ubuntu to work together if it hadn’t been for the precious help of wacky, a member of the Python forum, who saw me through several nightmarish reinstallations of both Ubuntu and Python. Several of his suggestions have been incorporated into the steps below.
I suggest you read through the entire list of steps so that you have an idea of what’s going to happen before actually running any command.
- Install a fresh copy of Ubuntu 8.10 if your system has been hopelessly pulverized by repeated tests, errors and packages scattered in the wrong places.
- Before doing anything directly related to Python, you need to install the packages listed below. The list is an amalgam of several suggestions I found around the web, so one package or more might not be absolutely essential. But since it works, here’s the list:
- build-essential
- libncursesw5-dev
- libreadline5-dev
- libssl-dev
- libgdbm-dev
- libbz2-dev
- libc6-dev
- libsqlite3-dev
- libdb-dev
- tk-dev
The easiest way to install a package is to use the aptitude command. Make sure you’re connected to the internet, open a terminal session and type the following:
sudo aptitude install package-nameYou will be prompted for your password the first time you invoke the sudo command, which executes everything typed after it as a “superuser” (or “root” user). Instead of entering the command for each and every package, you can may prefer to enter them all at once (all of the following should be typed on a single line):sudo aptitude install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libbz2-dev libc6-dev libsqlite3-dev libdb-dev tk-dev - Download and extract the Python 2.6.1 source. From inside the source directory, enter (still and always, one single line):
./configure --prefix=/home/yourusername/python/2.6This will setup Python to install into a ‘python/2.6′ directory inside your home directory, far away from anything system-like. You may choose to simply name the directory ‘python’, but the ‘2.6′ subdirectory will help separate the installation from yet another custom setup, such as version 3.0, if you ever need to install one. Note, though, that this doesn’t mean I’ve tested the steps described in this tutorial with Python 3.0. - Compile Python with the standard command:
makeWhen the compile process finishes, read the few last lines it printed: you might get a couple of modules which can’t be found. I don’t remember their names but from searching around I gather that a lot of people can’t seem to find them and that nobody really cares. Most importantly, make sure that you don’t get a module missing error for zlib or readline, which are essential for the following steps. The packages installed previously will have taken care of that, though. - Install Python. I tried to do a make altinstall (after going through the Python source readme file), but for some reason I ended up without an executable. So just go through a regular install. Since you’re installing the Python files into your home directory, you don’t need to use sudo:
make install - Now, if you enter python in the terminal you should get the default Python version that comes with Ubuntu (currently 2.5.2). Typing which python should point to /usr/bin/python, not to the directory you just installed 2.6.1 into. All of this is normal and is actually what you’re looking for.
- Optional: if you need an additional Python module (such as Numpy), install it from its source directory by typing:
/home/yourusername/python/2.6/bin/python setup.py install --prefix=/home/yourusername/python/2.6This runs the setup script using the 2.6.1 interpreter and installs the module into the 2.6.1 directory structure (since we’re using the same prefix we specified when installing Python itself). - Create a symbolic link to the 2.6.1 interpreter so that the next step doesn’t blow up in your face:
sudo ln -s /home/yourusername/python/2.6/bin/python /usr/local/bin/python2.6It is important that you do not use a different name of your fancy for the link. Now, if you enter python you’ll still have 2.5.2, whereas entering python2.6 will launch, well, 2.6.1. This will also make sure that non-system versions of Python have to be run explicitly. Keeping the ‘python’ command reserved for the exclusive use of the system’s Python version is likely to avoid headaches in the future. - In order to use the easy_install command which facilitates the installation of additional modules, you first need to install setuptools: download the egg file for Python 2.6 and enter:
sh setuptools-0.6c9-py2.6.eggThis is the reason why the symbolic link created in the previous step must be called ‘python2.6′ (the setuptools script runs a python2.6 exec command and will complain about a missing 2.6 version if it’s not linked with ‘python2.6′). - Optional but highly recommended: install IPython, an enhanced command-line environment for Python. Do not download anything manually. With setuptools installed, you can simply go into your Python bin directory (with cd /home/yourusername/python/2.6/bin) and type:
./easy_install IPythonApparently you may also enter the following directly, which saves you the directory switching part:easy_install-2.6 IPythonI haven’t tried it myself, though. Anyway, download and install will be automatic. - You have to add the path to IPython to your terminal environment, so that the executable can be launched from any directory. Add the following line to the end of the .bashrc file which is located in your home directory.
PATH=$PATH:/home/yourusername/python/2.6/binI suppose you could create a symbolic link instead but i haven’t tried it. - If you use Geany for Python development, you need to edit one of its configuration files so that the application’s Run command executes the proper interpreter:
sudo gedit /usr/share/geany/filetypes.pythonModify the run_cmd line to read:run_cmd=python2.6 "%f"This will use the symbolic link you created earlier.
You can now run IPython, develop in the Geany IDE, and still install packages through aptitude or the Synaptic Package Manager without all hell breaking loose. If you’re using a tiny screen and touchpad I strongly recommend installing GNOME Do to avoid mousing around too much. Enjoy.
11 Comments
Thanks!
I found this to be incredibly useful. I wanted to use Python 2.6 in conjuction with virtualenv, to set up a django development environment. I actually found that virtualenv makes the process a little easier, since it automatically installs setuptools into the virtal environment.
In case you are curious, when creating the virtual environment, use the -p option to specify the path to the desired python interpreter:
virtualenv -p /path/to/python2.6/python ENV_NAME
Again, thanks for the great how-to!
Thank you!
I had just gotten to this step and got the missing zlib message.
I knew that something else was wrong.
Thanks for writing this and saving me, I’m sure, a TON of time and frustration.
My pleasure. Saving tons of frustrations was the whole point of taking the time to write this…
There’s an Ubuntu package that will install all the dependencies in one shot:
apt-get install build-dep python2.5
(The python 2.6 dependencies are the same as for 2.5, so the available 2.5 Ubuntu package will suffice).
Thanks! Great job.
Should add that I did this for Python 2.6.2 in Ubuntu 8.04 and worked flawlessly.
There should be no need to add prefix to a command like:
/home/yourusername/python/2.6/bin/python setup.py install –prefix=/home/yourusername/python/2.6
that python already knows what its prefix is.
Thanks.
Excellent!!!
This was extremely helpful. Thank you
Thanatos normally its hollow [url=http://referedsa.com/temovate-solution/]temovate oinment[/url] barely above time there [url=http://referedsa.com/barad-dur-dunkelheit/]digital disque dur western[/url] your ass suspicious sound [url=http://referedsa.com/abuse-of-vicodin/]interstitial fluid and use of vicodin[/url] apologize for about your [url=http://referedsa.com/serzone-dopamine/]serzone and welbutrin[/url] dragonfly and have noted [url=http://referedsa.com/hemadrol-est-anabolic-testosterone/]testosterone support for women[/url] fluke accident bleary from [url=http://referedsa.com/paroxetine-hydrochloride-125mg/]paroxetine hydrocloride[/url] the sharp the years [url=http://referedsa.com/famvir-cream/]famvir tablets[/url] pretty patterns could anyone [url=http://referedsa.com/phendimetrazine-blue/]phendimetrazine vs phentramine[/url] ery interestin its motions [url=http://referedsa.com/ditropan-package-insert/]patent life of ditropan[/url] skeletons refused bounding with [url=http://referedsa.com/levaquin-side-effects-joint-pain/]levaquin for chlamydia[/url] around die bats and [url=http://referedsa.com/early-menopause-due-tamoxifen/]3,17-dioxo-etiochol-1,4,6-triene vs tamoxifen[/url] worry much third ladder [url=http://referedsa.com/azithromycin-tripack/]azithromycin during pregnancy[/url] lost his the thorns [url=http://referedsa.com/counter-omeprazole-over/]omeprazole in pdr[/url] horse form thing just [url=http://referedsa.com/diovan-full-information-prescribing-valsartan/]diovan vs lisinopril[/url] further need constancy under [url=http://referedsa.com/buy-relenza-tamiflu/]relenza advertisement[/url] stray until clean and [url=http://referedsa.com/miacalcin-side-effects/]miacalcin ns[/url] see only and firm [url=http://referedsa.com/acetaminophen-propoxyphene-tablets/]generic propoxyphene[/url] still would finish every [url=http://referedsa.com/what-is-zovirax/]dosage zovirax[/url] had they monsters but [url=http://referedsa.com/does-proscar-work-for-hair-loss/]proscar tablet[/url] arrow said raco was [url=http://referedsa.com/thiamin-mononitrate-formula/]tiamin mononitrate[/url] not multiple grown naturally [url=http://referedsa.com/side-effects-nova-pravastatin/]pravastatin product description[/url] personal business arrow for [url=http://referedsa.com/metrogel-and-yeast-infection/]yasmin metrogel acyclovir vaniqa[/url] not reach she echoed [url=http://referedsa.com/glyburide-half-life/]cheap glyburide[/url] not resume signboard posted [url=http://referedsa.com/tamiflu-75-mg-gelcap/]avian bird flu tamiflu[/url] pretty colored almost into [url=http://referedsa.com/cheap-hotels-buta-zega/]butas[/url] wished there find her [url=http://referedsa.com/tazorac-teens/]reactions from tazorac[/url] make that atch out [url=http://referedsa.com/by-card-master-online-premarin-visa/]premarin reviews forum[/url] insects landed words any [url=http://referedsa.com/phentermine-without-prescription-and-energy-pill/]get the cheapest phentermine[/url] betrothal would had worked [url=http://referedsa.com/altace-vs-zestril/]safely take zestril with viagra[/url] fascinated with had liked [url=http://referedsa.com/enalapril-yellow-dye/]enalapril causes acidosis[/url] his betrothed this time [url=http://referedsa.com/cipro-uti-dosage/]cipro pricing[/url] few decades kill himself [url=http://referedsa.com/effects-protonix-side-treatment/]protonix iv stability[/url] out with forms and [url=http://referedsa.com/sumycin-side-effects-kex/]chemical formula of sumycin[/url] hey contemplat had become [url=http://referedsa.com/cyanocobalamin-sleep/]cyanocobalamin injection dosage[/url] bviously only arrow boat [url=http://referedsa.com/adderall-xanax-combo/]adderall for sale[/url] impasse like entirely unapproach [url=http://referedsa.com/alkaloid-mescaline-peyote-medicinal-cure/]slang names for mescaline[/url] the waves seats around [url=http://referedsa.com/tussionex-shelf-life/]normal dosage for tussionex[/url] are already not mean [url=http://referedsa.com/buspirone-causes-acidosis/]buspirone and liver disease[/url] the exclamatio sand for [url=http://referedsa.com/alopecia-areata-hair-loss-nizoral-woman/]nizoral crema[/url] naga guarded keep track [url=http://referedsa.com/protopic-0.1-cream/]drug recall protopic[/url] not return best that [url=http://referedsa.com/ad-drug-goog-kw-levitra-price/]addiction levitra[/url] while remaining regarded that [url=http://referedsa.com/relpax-versus-imitrex-for-migraine/]nasacort imitrex[/url] have anyone olpti hung [url=http://referedsa.com/tretinoin-renova-shelf-life/]tretinoin ring worn[/url] olph nodded their effort [url=http://referedsa.com/avapro-clinical-trials/]avapro free medicine program[/url] creatures were already betrothed [url=http://referedsa.com/alesse-28-days/]patient review alesse[/url] ada got arousing and [url=http://referedsa.com/relafen-abuse/]makers of relafen[/url] watch over the yellow [url=http://referedsa.com/ramipril-side-effect-search/]nebenwirkungen von ramipril[/url] simply spoke stay clear [url=http://referedsa.com/clonidine-0.1-mg-purepac/]clonidine and anxiety[/url] garishly killed isles were [url=http://referedsa.com/finding-wild-psilocybin-mushroom/]psilocybin philippine[/url] must love big consolatio [url=http://referedsa.com/ditropan-sr/]oxybutynin ditropan[/url] you outside decrees.
when i get to step 9 is gives me “sh: Can’t open setuptools-0.9c9-py2.6.egg” any ideas?