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.

1pa
  • 715
  • 2
  • 9
  • 23
  • See http://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 '17 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- 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 '17 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 '17 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 '17 at 20:04
  • @1pati2 Did you activate the virtualenv? What error are you getting? – Ronan Lamy Feb 20 '17 at 20:28
  • @RonanLamy yes i wrote `source activate pypy-env` ` – 1pa Feb 20 '17 at 20:54
  • @RonanLamy then `pip install psycopg2cffi psycopg2cffi-compat` and i'm getting this error: `Command "/home/p/Desktop/pypy-env/bin/pypy -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ron22/psycopg2cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n','\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-cGNmfN-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/p/Desktop/pypy-env/include/site/python2.7/psycopg2cffi" failed with error code 1 in /tmp/pip-build-ron22h/psycopg2cffi/ – 1pa Feb 20 '17 at 20:55
  • @1pati2 Update pip (`pip install -U pip`) and see if it helps (e.g. by getting a less cryptic error)? If not, you should probably ask the psycopg2cffi maintainers. – Ronan Lamy Feb 20 '17 at 22:19
  • Does `pip_pypy` work? Depending on how it was installed, PyPy comes with its own pip, which can be run with `pip_pypy`. – numbermaniac Mar 13 '17 at 01:58

4 Answers4

72

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

pypy -m ensurepip
SebMa
  • 4,037
  • 29
  • 39
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
mbelsky
  • 6,093
  • 2
  • 26
  • 34
Mohamed Gamal
  • 501
  • 4
  • 3
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?

kleite
  • 195
  • 1
  • 16
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

FerranB
  • 35,683
  • 18
  • 66
  • 85
Ekremus
  • 237
  • 2
  • 4