I'm using pip with pypy3 on Ubuntu 22.04. Installing the "python3-pip" package or manipulating packages in a "pypy3-venv" seems to solve the problem. I prefer "pypy3-venv".
Start
# apt update && \
apt install software-properties-common && \
add-apt-repository ppa:pypy/ppa && \
apt install pypy3
# pypy3 --version
Python 3.9.19 (7.3.16+dfsg-2~ppa1~ubuntu22.04, Apr 26 2024, 13:22:45)
[PyPy 7.3.16 with GCC 11.4.0]
# python3 --version
Python 3.10.12
# pypy3 -m pip
/usr/bin/pypy3: No module named pip
(to install pip, you need to run once "/usr/bin/pypy3 -m ensurepip")
"python3" is a dependency of "software-properties-common".
The python3-pip way
I thought the "pypy3-pip" package existed, but:
# apt install pypy3-pip
E: Unable to locate package pypy3-pip
So I tried "python3-pip":
# apt install python3-pip
# pypy3 -m pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.9)
# python3 -m pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
Is the /usr/lib/python3/dist-packages/*
directory shared with python3 and pypy3? I don't know.
Install packages and their dependencies:
# apt install libpq-dev pypy3-dev && \
pypy3 -m pip install psycopg2cffi psycopg2cffi-compat && \
pypy3 -m pip list
...
WARNING: Running pip as the 'root' user can result in broken permissions
and conflicting behaviour with the system package manager. It is
recommended to use a virtual environment instead:
https://pip.pypa.io/warnings/venv
...
Package Version
------------------- -----------
...
psycopg2cffi 2.9.0
psycopg2cffi-compat 1.1
...
Then import "psycopg2cffi":
# pypy3 -c 'import psycopg2cffi'; echo $?
0
The pypy3-venv way
We can also deploy a "venv":
# apt install pypy3-venv && \
pypy3 -m venv .venv && \
source .venv/bin/activate
(.venv)
# which pypy3 python3 pip3 && pip3 --version
/.venv/bin/pypy3
/.venv/bin/python3
/.venv/bin/pip3
pip 22.0.2 from /.venv/lib/pypy3.9/site-packages/pip (python 3.9)
(.venv)
# apt install libpq-dev pypy3-dev && \
pip3 install psycopg2cffi psycopg2cffi-compat && \
pip3 list
...
(.venv)
# pypy3 -c 'import psycopg2cffi'; echo $?
0
# deactivate
# pypy3 -c 'import psycopg2cffi'; echo $?
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'psycopg2cffi'
1
Please note the package "python3-setuptools-whl":
# apt-cache depends pypy3-venv
pypy3-venv
Depends: pypy3
Depends: python3-pip-whl
Depends: python3-setuptools-whl
# dpkg -L python3-pip-whl
...
/usr/share/python-wheels/pip-22.0.2-py3-none-any.whl
.
./usr/bin/pypy -m ensurepip
i get this errorensurepip 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.
@ArminRigovirtualenv -p pypy3 pypy3-env
. (Note that an up-to-datevirtualenv
running on CPython2 is perfectly capable of creating pypy3 environments.)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?