Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to replace the default CPython (Python) with pypy (1.8).

Will this cause a problem? (I ask because python seems to be an important component in Ubuntu.).

I've built pypy and have installed it on a virtual machine of Ubuntu (I'm testing this idea out before I do it to my actual machine. So while we can try thing my intention is to accomplish this in "real life" as it were.).

Pypy is usable from the anywhere in the system via pypy as opposed to python.


It seems to be installed fine and seems usable.

Now, I want to make it so that any time I want to use python, it'll assume I mean pypy.

For example, I installed Django in to pypy but when I try to run it has no idea what I'm talking about. I imagine I could accomplish this part by adding wherever is to my $HOME variable.

That, for now, is aside the point.

So, my question is how do I replace standard python with my own preferred version -- in this case, pypy.

I'm revising my question based on the answer thus far -- that replacing CPython in whole is not a good idea as it could foobar the system.

I've read a bit on virtualenv -- looks good but it doesn't seem to answer my question (or, I'm missing how).

I want to use pypy for my work in python. Development work for things like, Django, Google App Engine and other such nonsense. (I realize there could be a compatibility issue, I'll address those with unit tests or some other means. Just know, it's beside the point at the moment.)

So, keeping this in mind, say I want to use pypy instead of python. And for ./ to work globally, it'd have to be installed with the system's python. How might I configure the system to support these "global" python scripts from either pypy or the main system python?

share|improve this question
could some one add a pypy tag to this, please. I could not 'create' the tag. – Frank V Feb 12 '12 at 1:00
up vote 3 down vote accepted

It is not a good idea to mess with system python because, as you have noticed, Ubuntu uses python widely so any change may render your system unstable.

Moreover, as a developer, I can tell you that globally installing third-party libraries into your system Python is not a good idea either - everything will start falling apart as soon as you have two projects which require different versions of Django, for example.

Luckily, Python has very good tools for creating isolated environments which may be completely independent from the system Python.

Have a look at virtualenv and zc.buildout (along with djangorecipe) for a civilized solution to your problem. :)

UPDATE: Very briefly, here's how zc.buildout would solve your problem:

You create a directory where you put and buildout.cfg file which contains

parts = django
versions = versions

django = 1.2.5

recipe = djangorecipe
settings = development
eggs = ${buildout:eggs}
project = mymegaapp

Then you run /path/to/python/interpreter/python, at which point your buildout "remembers" which python interpreter you used. It also creates a bin directory where all your "global" scripts will be auto-generated. Then you run bin/buildout, which downloads and installs Django of specified version, creates an empty project called "mymegaapp" etc. After it's finished, you'll find django command in the bin directory which is equivalent to, so you can run

bin/django syncdb
bin/django runserver

etc. You never have to worry to remember to use the correct interpreter. Of course, this is just a very small part of what you can do with buildout... just think about putting buildout.cfg into a VCS so you can re-build the application with all the dependencies at exact versions, even in a few years from now... or about having multiple configs for different "deployment configurations" :)

For a quick example how to do this with virtualenv you can have a look at this article - the instructions should work apart from the very first part - you'll need to install setuptools with your pypy, not with the 'standard' interpreter. Then you'll use python script generated in your sandbox's bin directory:

cd myapp
../venv/bin/python runserver

(I have a feeling the question becomes less and less relevant to Ubuntu... should we ask for it to be migrated to stackoverflow?)

share|improve this answer
Ok, fair. You've asked the first part of my question. I won't try to wholly replace python. I'm going to revise my question based on your feedback. – Frank V Feb 12 '12 at 16:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.