spine-tools / Spine-Toolbox

Spine Toolbox is an open source Python package to manage data, scenarios and workflows for modelling and simulation. You can have your local workflow, but work as a team through version control and SQL databases.
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
73 stars 18 forks source link

psycopg2 and Pyside6 not working yet in Python 3.13 #2986

Open jkiviluo opened 1 month ago

jkiviluo commented 1 month ago

python -m pip install -r requirements.txt on Windows 11, Python 3.13

Fails with

Collecting psycopg2 (from spinedb_api->-r requirements.txt (line 1))
  Downloading psycopg2-2.9.10.tar.gz (385 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running egg_info
      writing psycopg2.egg-info\PKG-INFO
      writing dependency_links to psycopg2.egg-info\dependency_links.txt
      writing top-level names to psycopg2.egg-info\top_level.txt

      Error: pg_config executable not found.

      pg_config is required to build psycopg2 from source.  Please add the directory
      containing pg_config to the $PATH or specify the full executable path with the
      option:

          python setup.py build_ext --pg-config /path/to/pg_config build ...

      or with the pg_config option in 'setup.cfg'.

      If you prefer to avoid building psycopg2 from source, please install the PyPI
      'psycopg2-binary' package instead.

      For further information please check the 'doc/src/install.rst' file (also at
      <https://www.psycopg.org/docs/install.html>).

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
jkiviluo commented 1 month ago

Tried with Python 3.11.9 and it works fine.

soininen commented 1 month ago

Apparently psycopg2 nowadays requires a C compiler to install which I guess is a no-go even if they fix the build on Python 3.13. We could switch to the precompiled psycopg2-binary module instead.

(psycopg2 is used by SqlAlchemy to access postgresql databases, which we support in Importer and Exporter)

soininen commented 1 month ago

Looks like psycopg2-binary has the same build issue on Windows as psycopg2. Not sure how to proceed.

soininen commented 1 month ago

psycopg2 and psycopg2-binary install on my Windows 10 + Python 3.8 system without problems. Could this be a Windows 11 issue?

soininen commented 1 month ago

I think I get it now: psycopg2 still does not have built packages for Windows + Python 3.13. Also, the packages are missing for Python 3.8 which makes our unit test GitHub actions fail.

jkiviluo commented 1 month ago

Ok, I also wondered why my attempt to use psycopg2-binary failed. Does it mean that we just need to say not to use 3.13 for now?

soininen commented 1 month ago

Does it mean that we just need to say not to use 3.13 for now?

Yes. I've now set the required Python to be between 3.9 and 3.13 for the time being. We should lift the upper bound once psycopg2 and PySide6 have working packages for 3.13.

jkiviluo commented 2 weeks ago

Same thing in https://github.com/spine-tools/Spine-Toolbox/issues/2985