Skip to main content

Command Palette

Search for a command to run...

How to Install PyPy and Use it?

Updated
3 min read
How to Install PyPy and Use it?
S

I am a self-taught Python developer who loves to write on Python Programming and quite obsessed with Machine Learning.

PyPy is an implementation of Python written in RPython (Reduced Python) language, and it is seen as a replacement for CPython.

PyPy claims that it is almost a drop-in replacement for CPython and can beat it on speed and memory usage. It supports libraries like Django, NumPy, Scikit-learn, and Twisted, and comes with the stackless mode, providing micro-threads for massive concurrency.

In this article, we’ll see how to install and use PyPy in our system.

Installation

PyPy comes with Python3 and Python2. Click here to download the pre-built binary that is compatible with your system.

Download PyPy

After downloading PyPy, you’ll get a compressed folder in your system. Now extract the content of the PyPy’s build folder into the desired path, and that’s it.

Extracted PyPy build

But how to use it because we didn’t add PyPy’s path to system variables like we used to do in the case of CPython installation?

How to Use PyPy?

It is recommended to use PyPy using a virtual environment. Let’s see how we can use PyPy from a virtual environment.

We’ll use virtualenv package to create a virtual environment. It is compatible with both CPython and PyPy. You’ll need to install this package (pip install virtualenv) to get started.

Open the command prompt or terminal and run the following command:

PS > virtualenv -p D:/SACHIN/pypy310/pypy.exe pypyenv

Let’s understand what the above command does:

  • virtualenv: A command to create a virtual environment using virtualenv.

  • -p: Specifies the path to the Python interpreter that will be used in the virtual environment. It can also be written --python.

  • D:/SACHIN/pypy310/pypy.exe: Path to PyPy interpreter.

  • pypyenv: Species the name of the virtual environment.

Run the command and PyPy will be ready to use.

You can check if you are using PyPy by running the following command:

PS > cd pypyenv
PS > Scripts/activate
(pypyenv) PS > cd ..
(pypyenv) PS > python --version
Python 3.10.14 (39dc8d3c85a7, Aug 27 2024, 14:33:33)
[PyPy 7.3.17 with MSC v.1929 64 bit (AMD64)]

You’ll notice that we used python command to check the version of PyPy installed on the system because in the virtual environment, the python command becomes a symlink (or equivalent) to the interpreter used when creating the virtual environment.

Installing Modules Using PyPy

The following command is used to install third-party modules using PyPy:

PS > pypy -m pip install module_name

You can directly install modules without writing pypy -m, if you are using PyPy as the main interpreter. If you are using PyPy within an isolated environment then activate the environment and use the above command to avoid any error.

Some third-party libraries such as Scipy create problems during the installation, so in that case, you can use conda with pypy3.9.


That’s all for now.

Keep Coding✌✌

E
Erik Berg7mo ago

I still can’t believe what happened to me! For years, I struggled to win anything from the lottery until I came across Dr. Benjamin, a powerful spell caster. At first, I was skeptical, but after speaking with him, I decided to give it a try. Dr. Benjamin prepared a special spell and gave me the exact lottery numbers to play. I followed his instructions carefully, and to my greatest surprise, I hit the Powerball jackpot worth $340,000,000.00! My life has completely changed overnight — from financial struggles to total freedom. I can now take care of my family, help people in need, and live the kind of life I always dreamed of. Dr. Benjamin is truly a blessing, and I’ll forever be grateful for his amazing help. I promise not to ever stop telling people about the goods works you've done in my life.. If you need his help reach him today via email drbenjaminlottospell711@gmail.com