eGenix / egenix-pyrun

eGenix PyRun - Your friendly, lean, open source Python runtime
https://pyrun.org
Apache License 2.0
30 stars 0 forks source link

ModuleNotFoundError: No module named '_ctypes' #13

Open jedie opened 1 month ago

jedie commented 1 month ago

Try to use psycopg with eGenix PyRun 3.11.9 (release 2.5.0) results in:

Traceback (most recent call last):
  File "<pyrun>/pyrun3.11.py", line 52, in <module>
  File "<pyrun>/pyrun_main.py", line 912, in pyrun_main
  File "<pyrun>/pyrun_main.py", line 813, in pyrun_execute_script
  File "<stdin>", line 1, in <module>
  File "/tmp/pyruntest/lib/python3.11/site-packages/psycopg/__init__.py", line 9, in <module>
    from . import pq  # noqa: F401 import early to stabilize side effects
    ^^^^^^^^^^^^^^^^
  File "/tmp/pyruntest/lib/python3.11/site-packages/psycopg/pq/__init__.py", line 19, in <module>
    from .misc import ConninfoOption, PGnotify, PGresAttDesc
  File "/tmp/pyruntest/lib/python3.11/site-packages/psycopg/pq/misc.py", line 13, in <module>
    import ctypes.util
  File "<pyrun>/ctypes/__init__.py", line 8, in <module>
ModuleNotFoundError: No module named '_ctypes'

script to test this:

#!/bin/bash

set -e

VERSION=3.11

PYRUN=~/.local/bin/pyrun${VERSION}

${PYRUN} -V
${PYRUN} -m venv --without-pip /tmp/pyruntest

ls -la /tmp/pyruntest/bin
/tmp/pyruntest/bin/pyrun${VERSION} -V

# pyrun error: Could not run 'ensurepip': No module named ensurepip
#/tmp/pyruntest/bin/pyrun${VERSION} -m ensurepip

# pyrun error: Could not run 'pip': No module named pip
# /tmp/pyruntest/bin/pyrun${VERSION} -m pip install --upgrade pip

cd /tmp
wget --timestamp https://bootstrap.pypa.io/get-pip.py

/tmp/pyruntest/bin/pyrun${VERSION} /tmp/get-pip.py

/tmp/pyruntest/bin/pyrun${VERSION} -m pip -V
/tmp/pyruntest/bin/pyrun${VERSION} -m pip install --upgrade pip

/tmp/pyruntest/bin/pyrun${VERSION} -m pip install -U psycopg[binary]

/tmp/pyruntest/bin/pyrun${VERSION} -c "import psycopg; print(psycopg.__version__)"