39

I want to speed up my program so i'm trying to setup pypy + psycopg2cffi. This program opens a xml, parses it and then insert some data in a database. I'm using currently python3, postgresql and psycopg2 but this approaches is really slow. So i want to try run my program with pypy + psycopg2cffi. I have python 3 and pypy, and i want to install psycopg2cffi so i ran this command:

pip install psycopg2cffi psycopg2cffi-compat 

But psycopg2cffi was only installed on python because when i try to import psycopg2cffi on pypy this is the error i get:

ImportError: No module named psycopg2cffi

So i think i need to install pip first but i can figure out how to do this.

How can i install it on pypy? Thank you.

9
  • See doc.pypy.org/en/latest/install.html#installing-more-modules . Note also that the officially released PyPy-for-3.x is old and slow; better wait for the next one (or use PyPy-for-2.7).
    – Armin Rigo
    Feb 20, 2017 at 14:11
  • when i try to run ./usr/bin/pypy -m ensurepip i get this error ensurepip is disabled in Debian/Ubuntu for the system python. Python modules For the system python are usually handled by dpkg and apt-get. apt-get install pypy-<module name> Install the python-pip package to use pip itself. Using pip together with the system python might have unexpected results for any system installed module, so use it on your own risk, or make sure to only use it in virtual environments. @ArminRigo
    – 1pa
    Feb 20, 2017 at 15:58
  • 1
    IMO, the only sensible way of using pypy3 on Debian/Ubuntu is to create a virtualenv for it, using something like virtualenv -p pypy3 pypy3-env. (Note that an up-to-date virtualenv running on CPython2 is perfectly capable of creating pypy3 environments.)
    – Ronan Lamy
    Feb 20, 2017 at 18:21
  • thank you!! @RonanLamy Now i have pip: /usr/local/bin/pip /usr/local/bin/pip2.7 /home/p/Desktop/pypy-env/bin/pip /home/p/Desktop/pypy-env/bin/pip2.7 /home/anaconda3/bin/pip and even with pip i can't install psycopg2cffi on pypy why?
    – 1pa
    Feb 20, 2017 at 20:04
  • @1pati2 Did you activate the virtualenv? What error are you getting?
    – Ronan Lamy
    Feb 20, 2017 at 20:28

4 Answers 4

73

You can also try this (if it's not disabled in your Linux distribution):

pypy -m ensurepip
3
  • 8
    Works great, this saves the trouble of downloading get-pip.py. Also works on Windows.
    – gaborous
    Aug 5, 2017 at 2:46
  • 3
    Why is this disabled on some linux distros, and how can it be enabled? Oct 10, 2019 at 22:35
  • 9
    ensurepip is disabled in Debian/Ubuntu for the system python.
    – Pygmalion
    Dec 4, 2019 at 16:14
50

Download the pip-installer and execute it with pypy:

wget https://bootstrap.pypa.io/get-pip.py
./pypy get-pip.py

For usage try,

pypy -m pip install validators
2
  • On my win10 (1809) and PyPy 7.3.1, get-pip.py crashed on compilation.
    – Fred Qian
    Apr 16, 2020 at 3:09
  • ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.7. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
    – Galen
    Oct 15 at 2:15
4

For me, "pypy -m ensurepip" didn't work with a pypy3 installed with apt-get under Kubuntu 20.04. Probably disabled in the repository, as comments point in @SebMa answer. I was trying to run sympy with pypy3, so I needed pip working with pypy3. I managed to get it working with pypy3 installed with Anaconda:

conda config --set channel_priority strict
conda create -n pypy3 -c conda-forge pypy3.6
conda activate pypy3
pypy3 -m ensurepip
pypy3 -m pip install sympy

This question and its answers were also helpful: How to create a Conda environment that uses PyPy?

3

I installed pip via

wget https://bootstrap.pypa.io/get-pip.py
pypy3 get-pip.py

then

pypy3 -m pip install "module"

solved my issue. @kleite thanx

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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