Using Python PyPy in a virtual environment

Posted on Fri 18 December 2015 in HowTo, Python • Tagged with pypy, Python

Sometimes we need to test if our code also works with PyPy implementation of Python. Assuming you have already installed it in your system, first find out where it is installed:

which pypy
/usr/local/bin/pypy

then you need mkvirtualenv to create a virtual environment that will use this runtime:

mkvirtualenv -p /usr/local/bin/pypy pypy-test
Running virtualenv with interpreter /usr/local/bin/pypy
New pypy executable in pypy-test/bin/pypy
Installing setuptools, pip, wheel...done.
(pypy-test)➜  ~  python
Python 2.7.10 (f3ad1e1e1d6215e20d34bb65ab85ff9188c9f559, Sep 01 2015, 06:26:30)
[PyPy 2.6.1 with GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>>

That's it! You can now use this virtual environment to run your Python application using PyPy environment.