actions / setup-python

Set up your GitHub Actions workflow with a specific version of Python
MIT License
1.68k stars 538 forks source link

Importing psycopg2 (installed via pip) reports: ImportError: /opt/hostedtoolcache/.../3.13.0-alpha.6/.../psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get #848

Closed rouilj closed 4 months ago

rouilj commented 5 months ago

Description: Running 3.13-alpha.6, I install psycopg2 using pip install. When my program does an import psycopg2, I get the error:

 ImportError: /opt/hostedtoolcache/Python/3.13.0-alpha.6/x64/lib/python3.13/site-packages/psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get

Action version:

        uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0

Platform:

Runner type:

Tools version:

Python: 3.13-alpha.6 psycopg2: 2.9.9 Ubuntu: 22.04 runner (latest)

This same workflow works fine on 3.6->3.12.

Repro steps:
As far as I can tell this minimal test case should reproduce it:

I can't get a shell inside a runner to test however so...

See https://github.com/roundup-tracker/roundup/actions/runs/8767065771/job/24059915708 for a full run including the error.

Expected behavior: I expect the import to succeed without an ImportError.

Actual behavior: The import fails with an ImportError:

Traceback (most recent call last):
  File "/home/runner/work/roundup/roundup/setup.py", line 275, in <module>
    main()
    ~~~~^^
  File "/home/runner/work/roundup/roundup/setup.py", line 152, in main
    from roundup.init import listTemplates
  File "/home/runner/work/roundup/roundup/roundup/init.py", line 29, in <module>
    from roundup.configuration import CoreConfig
  File "/home/runner/work/roundup/roundup/roundup/configuration.py", line 358, in <module>
    class DatabaseBackend(Option):
    ...<8 lines>...
                raise OptionValueError(self, value, self.class_description)
  File "/home/runner/work/roundup/roundup/roundup/configuration.py", line 360, in DatabaseBackend
    class_description = "Available backends: %s" % ", ".join(list_backends())
                                                             ~~~~~~~~~~~~~^^
  File "/home/runner/work/roundup/roundup/roundup/backends/__init__.py", line 80, in list_backends
    if have_backend(name):
       ~~~~~~~~~~~~^^^^^^
  File "/home/runner/work/roundup/roundup/roundup/backends/__init__.py", line 49, in have_backend
    get_backend(name)
    ~~~~~~~~~~~^^^^^^
  File "/home/runner/work/roundup/roundup/roundup/backends/__init__.py", line 42, in get_backend
    module = __import__(module_name, vars, level=1)
             ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/roundup/roundup/roundup/backends/back_postgresql.py", line 21, in <module>
    import psycopg2                                                   # noqa: E402
    ^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.0-alpha.6/x[64](https://github.com/roundup-tracker/roundup/actions/runs/8767065771/job/24059915708#step:17:65)/lib/python3.13/site-packages/psycopg2/__init__.py", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
    ...<10 lines>...
    )
ImportError: /opt/hostedtoolcache/Python/3.13.0-alpha.6/x64/lib/python3.13/site-packages/psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get
Error: Process completed with exit code 1.

See https://github.com/roundup-tracker/roundup/actions/runs/8767065771/job/24059915708 for a full run including the error.

Thanks for any help/ideas on how to debug.

-- rouilj

rouilj commented 4 months ago

This appears to compile with python 3.13 beta 1. However it crashed when imported with:

ImportError: /opt/hostedtoolcache/Python/3.13.0-beta.1/x64/lib/python3.13/site-packages/psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get

I'll open a new issue for this crash.