psycopg2 icon indicating copy to clipboard operation
psycopg2 copied to clipboard

Add Python 3.13 packages for Windows

Open dvarrazzo opened this issue 1 year ago • 1 comments

Packages for other platforms already released: see #1692.

For Windows we need https://github.com/appveyor/ci/issues/3927

dvarrazzo avatar Oct 16 '24 11:10 dvarrazzo

@dvarrazzo Thanks for making note of this, this is currently impacting our team

Fingers crossed will be resolved soon. Have a great one 😇

Erik-Stodola-Enerfrog avatar Oct 16 '24 20:10 Erik-Stodola-Enerfrog

Exception has occurred: ImportError DLL load failed while importing _psycopg: The specified module could not be found. File "C:\Users\Desktop\pg_connect.py", line 1, in import psycopg2 ImportError: DLL load failed while importing _psycopg: The specified module could not be found.

I am using the latest version of python 3.13, on windows OS. so during my pip install psycopg2 the wheel build failed as i didn't install visual studio buildtools, once this was downloaded, the installation happened smoothly. But while running the code i am getting this error. Any help would be much appreciated!

Version of psycopg2 == 2.9.10

muizz-IHT avatar Oct 31 '24 08:10 muizz-IHT

I have the same problem as @muizz-IHT when I try to import psycopg2 on Python 3.13 (Windows OS).

Traceback (most recent call last): File "", line 1, in import psycopg2 File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\psycopg2_init_.py", line 51, in from psycopg2._psycopg import ( # noqa ...<10 lines>... ) ImportError: DLL load failed while importing _psycopg: No se puede encontrar el módulo especificado.

Any help would be much appreciated!

Loparch avatar Nov 02 '24 23:11 Loparch

I am also having this exact issue. @muizz-IHT and @Loparch. I am on python 13. tried downgrading and that didnt help. Installed using pip install pyscopg2-binary, uninstalled and reinstalled a few times. Installed the visual studio C+ tools, etc. Tried everything I could now posting this here. The issue for me happens here:

$ c:/Users/myuser/Home/Development/venv2/Scripts/python.exe c:/Users/myuser/Home/Development/app/main.py
Traceback (most recent call last):
  File "c:\Users\myuser\Home\Development\app\main.py", line 30, in <module>
    engine=create_engine(DATABASE_URL)
  File "<string>", line 2, in create_engine
  File "C:\Users\myuser\Home\Development\venv2\Lib\site-packages\sqlalchemy\util\deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
  File "C:\Users\myuser\Home\Development\venv2\Lib\site-packages\sqlalchemy\engine\create.py", line 599, in create_engine
    dbapi = dbapi_meth(**dbapi_args)
  File "C:\Users\myuser\Home\Development\venv2\Lib\site-packages\sqlalchemy\dialects\postgresql\psycopg2.py", line 690, in import_dbapi
    import psycopg2
  File "C:\Users\myuser\Home\Development\venv2\Lib\site-packages\psycopg2\__init__.py", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
    ...<10 lines>...
    )
ImportError: DLL load failed while importing _psycopg: The specified module could not be found.
(venv2) 

stephenjoly avatar Nov 07 '24 14:11 stephenjoly

Is there a change to workaround this by using Github Actions instead or Python 3.13rc1 on Appvayer?

offa avatar Nov 08 '24 09:11 offa

Since Python 13 was just released in October, many library wheels and binaries haven’t been built yet. I tried using Python 12, which has been out for a year, and psycopg2 worked flawlessly. It’s also recommended to install Visual Studio Build Tools for C++ to ensure everything runs smoothly. check the vsbuild installer here

muizz-IHT avatar Nov 08 '24 11:11 muizz-IHT

I can't install psycopg2-binary for python 3.13 on Windows 10.

C:\WINDOWS\system32>python -m pip install psycopg2-binary
Collecting psycopg2-binary
  Using cached psycopg2-binary-2.9.10.tar.gz (385 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: psycopg2-binary
  Building wheel for psycopg2-binary (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for psycopg2-binary (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build\lib.win-amd64-cpython-313\psycopg2
      copying lib\errorcodes.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\errors.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\extensions.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\extras.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\pool.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\sql.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\tz.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\_ipaddress.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\_json.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\_range.py -> build\lib.win-amd64-cpython-313\psycopg2
      copying lib\__init__.py -> build\lib.win-amd64-cpython-313\psycopg2
      running build_ext
      building 'psycopg2._psycopg' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for psycopg2-binary
Failed to build psycopg2-binary
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (psycopg2-binary)

I've tryed to install Microsoft Visual C++ but it doesn't help. I would like to have psycopg2-binary ready for use without reistalling OS.

ninabel avatar Nov 14 '24 14:11 ninabel

@ninabel You are not required to reinstall OS. You can use Python 3.12 or move your project to psycopg 3.

dvarrazzo avatar Nov 15 '24 08:11 dvarrazzo

@dvarrazzo Thanks for your help, we appreciate it. Using psycopg 3 has unblocked our team. Thank you! 😇🎖️

Official Python Packages - psycopg

Erik-Stodola-Enerfrog avatar Nov 15 '24 16:11 Erik-Stodola-Enerfrog

Note: in psycopg 3 there is already support for Python 3.13 and it doesn't require appveyor, see https://github.com/psycopg/psycopg/pull/966.

I would like to backport the same procedure to drop the dependency on appveyor, which is never timely enough in introducing new Python versions.

dvarrazzo avatar Jan 04 '25 11:01 dvarrazzo

Python 3.13 psycopg2-binary packages for Windows released. We don't depend on Appveyor anymore to build these packages.

dvarrazzo avatar Jan 04 '25 20:01 dvarrazzo

@dvarrazzo the psycopg2-2.9.10-cp313-cp313-win_amd64.whl wheel (from the latest release above) is detected via poetry on linux installs but not OSX installs, causing inconsistency in poetry.lock files between operating systems:

On linux

[[package]]
name = "psycopg2"
version = "2.9.10"
description = "psycopg2 - Python-PostgreSQL Database Adapter"
optional = false
python-versions = ">=3.8"
files = [
    {file = "psycopg2-2.9.10-cp310-cp310-win32.whl", hash = "sha256:5df2b672140f95adb453af93a7d669d7a7bf0a56bcd26f1502329166f4a61716"},
    {file = "psycopg2-2.9.10-cp310-cp310-win_amd64.whl", hash = "sha256:c6f7b8561225f9e711a9c47087388a97fdc948211c10a4bccbf0ba68ab7b3b5a"},
    {file = "psycopg2-2.9.10-cp311-cp311-win32.whl", hash = "sha256:47c4f9875125344f4c2b870e41b6aad585901318068acd01de93f3677a6522c2"},
    {file = "psycopg2-2.9.10-cp311-cp311-win_amd64.whl", hash = "sha256:0435034157049f6846e95103bd8f5a668788dd913a7c30162ca9503fdf542cb4"},
    {file = "psycopg2-2.9.10-cp312-cp312-win32.whl", hash = "sha256:65a63d7ab0e067e2cdb3cf266de39663203d38d6a8ed97f5ca0cb315c73fe067"},
    {file = "psycopg2-2.9.10-cp312-cp312-win_amd64.whl", hash = "sha256:4a579d6243da40a7b3182e0430493dbd55950c493d8c68f4eec0b302f6bbf20e"},
    {file = "psycopg2-2.9.10-cp313-cp313-win_amd64.whl", hash = "sha256:91fd603a2155da8d0cfcdbf8ab24a2d54bca72795b90d2a3ed2b6da8d979dee2"},
    {file = "psycopg2-2.9.10-cp39-cp39-win32.whl", hash = "sha256:9d5b3b94b79a844a986d029eee38998232451119ad653aea42bb9220a8c5066b"},
    {file = "psycopg2-2.9.10-cp39-cp39-win_amd64.whl", hash = "sha256:88138c8dedcbfa96408023ea2b0c369eda40fe5d75002c0964c78f46f11fa442"},
    {file = "psycopg2-2.9.10.tar.gz", hash = "sha256:12ec0b40b0273f95296233e8750441339298e6a572f7039da5b260e3c8b60e11"},
]

On OSX

[[package]]
name = "psycopg2"
version = "2.9.10"
description = "psycopg2 - Python-PostgreSQL Database Adapter"
optional = false
python-versions = ">=3.8"
files = [
    {file = "psycopg2-2.9.10-cp310-cp310-win32.whl", hash = "sha256:5df2b672140f95adb453af93a7d669d7a7bf0a56bcd26f1502329166f4a61716"},
    {file = "psycopg2-2.9.10-cp310-cp310-win_amd64.whl", hash = "sha256:c6f7b8561225f9e711a9c47087388a97fdc948211c10a4bccbf0ba68ab7b3b5a"},
    {file = "psycopg2-2.9.10-cp311-cp311-win32.whl", hash = "sha256:47c4f9875125344f4c2b870e41b6aad585901318068acd01de93f3677a6522c2"},
    {file = "psycopg2-2.9.10-cp311-cp311-win_amd64.whl", hash = "sha256:0435034157049f6846e95103bd8f5a668788dd913a7c30162ca9503fdf542cb4"},
    {file = "psycopg2-2.9.10-cp312-cp312-win32.whl", hash = "sha256:65a63d7ab0e067e2cdb3cf266de39663203d38d6a8ed97f5ca0cb315c73fe067"},
    {file = "psycopg2-2.9.10-cp312-cp312-win_amd64.whl", hash = "sha256:4a579d6243da40a7b3182e0430493dbd55950c493d8c68f4eec0b302f6bbf20e"},
    {file = "psycopg2-2.9.10-cp39-cp39-win32.whl", hash = "sha256:9d5b3b94b79a844a986d029eee38998232451119ad653aea42bb9220a8c5066b"},
    {file = "psycopg2-2.9.10-cp39-cp39-win_amd64.whl", hash = "sha256:88138c8dedcbfa96408023ea2b0c369eda40fe5d75002c0964c78f46f11fa442"},
    {file = "psycopg2-2.9.10.tar.gz", hash = "sha256:12ec0b40b0273f95296233e8750441339298e6a572f7039da5b260e3c8b60e11"},
]

emilhdiaz avatar Jan 08 '25 21:01 emilhdiaz

@emilhdiaz you probably need to run poetry cache clear pypi --all on your mac

edgarrmondragon avatar Jan 08 '25 21:01 edgarrmondragon

Thanks @edgarrmondragon! That indeed cleared the issue on my Mac.

emilhdiaz avatar Jan 08 '25 21:01 emilhdiaz