Incompatible with latest langchain-community version due to numpy dependency #73

Closed
opened 2026-02-16 05:16:26 -05:00 by yindo · 4 comments
Owner

Originally created by @jKlag on GitHub (Apr 23, 2025).

Originally assigned to: @dishaprakash on GitHub.

After langchain-community's latest updates to its numpy dependencies (in release v0.3.22), langchain-postgres can no longer be installed in the same environment:

12.31 ERROR: Cannot install -r requirements.txt (line 21) and -r requirements.txt (line 23) because these package versions have conflicting dependencies.
12.31 
12.31 The conflict is caused by:
12.31     langchain-community 0.3.22 depends on numpy>=2.1.0; python_version >= "3.13"
12.31     langchain-postgres 0.0.14 depends on numpy<2.0 and >=1.21

I believe the numpy dependency in this package (currently numpy = "^1.21") will need to be updated to something >=2.1.0 in order to resolve this issue.

Originally created by @jKlag on GitHub (Apr 23, 2025). Originally assigned to: @dishaprakash on GitHub. After `langchain-community`'s latest updates to its `numpy` dependencies (in [release v0.3.22](https://github.com/langchain-ai/langchain/releases/tag/langchain-community%3D%3D0.3.22)), `langchain-postgres` can no longer be installed in the same environment: ``` 12.31 ERROR: Cannot install -r requirements.txt (line 21) and -r requirements.txt (line 23) because these package versions have conflicting dependencies. 12.31 12.31 The conflict is caused by: 12.31 langchain-community 0.3.22 depends on numpy>=2.1.0; python_version >= "3.13" 12.31 langchain-postgres 0.0.14 depends on numpy<2.0 and >=1.21 ``` I believe the numpy dependency in this package (currently `numpy = "^1.21"`) will need to be updated to something `>=2.1.0` in order to resolve this issue.
yindo closed this issue 2026-02-16 05:16:26 -05:00
Author
Owner

@krauhen commented on GitHub (May 7, 2025):

Is there an easy solution?
I have currentlly a workaround. I cloned this repository, changed the pyproject.toml and install langchain-postgres from local for my application.

tmp/langchain-postgres/pyproject.toml

...

[tool.poetry.dependencies]
# python = "^3.9"
python = ">=3.11,<=3.13"
langchain-core = ">=0.2.13,<0.4.0"
psycopg = "^3"
psycopg-pool = "^3.2.1"
sqlalchemy = "^2"
pgvector = ">=0.2.5,<0.4"
# numpy = "^1.21"
asyncpg = "^0.30.0"
numpy = "^2.2.5"

...

[tool.poetry.group.test.dependencies]
greenlet = "<4"
pytest = "^7.4.3"
pytest-asyncio = "^0.23.2"
pytest-socket = "^0.7.0"
pytest-cov = "^5.0.0"
pytest-timeout = "^2.3.1"
# langchain-tests = "0.3.7"

...

my-app/pyproject.toml


...

[tool.poetry.dependencies]
python = ">=3.11,<=3.13"

...

langchain-postgres = {path = "tmp/langchain-postgres"}

...

Clearly not an ideal solution but i did not run into issues. What is the reason to limit numpy to be lower than 2.0?

@krauhen commented on GitHub (May 7, 2025): Is there an easy solution? I have currentlly a workaround. I cloned this repository, changed the pyproject.toml and install langchain-postgres from local for my application. # tmp/langchain-postgres/pyproject.toml ``` ... [tool.poetry.dependencies] # python = "^3.9" python = ">=3.11,<=3.13" langchain-core = ">=0.2.13,<0.4.0" psycopg = "^3" psycopg-pool = "^3.2.1" sqlalchemy = "^2" pgvector = ">=0.2.5,<0.4" # numpy = "^1.21" asyncpg = "^0.30.0" numpy = "^2.2.5" ... [tool.poetry.group.test.dependencies] greenlet = "<4" pytest = "^7.4.3" pytest-asyncio = "^0.23.2" pytest-socket = "^0.7.0" pytest-cov = "^5.0.0" pytest-timeout = "^2.3.1" # langchain-tests = "0.3.7" ... ``` # my-app/pyproject.toml ``` ... [tool.poetry.dependencies] python = ">=3.11,<=3.13" ... langchain-postgres = {path = "tmp/langchain-postgres"} ... ``` Clearly not an ideal solution but i did not run into issues. What is the reason to limit numpy to be lower than 2.0?
Author
Owner

@kozlek commented on GitHub (May 7, 2025):

The problem comes mainly from langchain-community.
The last version of Numpy 1.x was released before Python 3.13 so there is no wheel available on PyPi for Python 3.13. It seems some of their users don't know how to setup a proper toolchain to allow pip to build a wheel from source, so they enforced Numpy 2.x for Python 3.13 users.
See https://github.com/langchain-ai/langchain/issues/26026

This is a working solution to avoid users complaints, but it doesn't make any sense from a programming perspective...

On our side, we have two choices:

  • enforce numpy 2.x for all python versions (simple choice)
  • enforce numpy 2.x for python 3.13 only, using the same kind of constraints they use in langchain-community.

In both cases, we need to ensure our code is compatible with Numpy 2.x.
Version 2 was allowed before, but version 1.x was enforced with the switch PGVectorStore.
Are we sure we have code incompatible with 2.x ?

@kozlek commented on GitHub (May 7, 2025): The problem comes mainly from `langchain-community`. The last version of `Numpy 1.x` was released before Python 3.13 so there is no wheel available on PyPi for Python 3.13. It seems some of their users don't know how to setup a proper toolchain to allow pip to build a wheel from source, so they enforced `Numpy 2.x` for Python 3.13 users. See https://github.com/langchain-ai/langchain/issues/26026 This is a working solution to avoid users complaints, but it doesn't make any sense from a programming perspective... On our side, we have two choices: - enforce numpy 2.x for all python versions (simple choice) - enforce numpy 2.x for python 3.13 only, using the same kind of constraints they use in `langchain-community`. In both cases, we need to ensure our code is compatible with `Numpy 2.x`. Version 2 was allowed before, but version 1.x was enforced with the switch `PGVectorStore`. Are we sure we have code incompatible with 2.x ?
Author
Owner

@kozlek commented on GitHub (May 7, 2025):

According to Numpy documentation, there is a ruff rule that can check if we still use 1.x only functions or constants: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#ruff-plugin

After running the check on the whole repo (ruff check . --select NPY201), it seems we are good to go.

Additionally, our dependencies all support Numpy 2.

@kozlek commented on GitHub (May 7, 2025): According to Numpy documentation, there is a `ruff` rule that can check if we still use 1.x only functions or constants: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#ruff-plugin After running the check on the whole repo (`ruff check . --select NPY201`), it seems we are good to go. Additionally, our dependencies all support `Numpy 2`.
Author
Owner

@kozlek commented on GitHub (May 7, 2025):

After setting an environment with Python 3.13 and numpy 2.x, all the tests are passing.
I opened a PR to allow numpy 2.x installation: https://github.com/langchain-ai/langchain-postgres/pull/208

@kozlek commented on GitHub (May 7, 2025): After setting an environment with Python 3.13 and numpy 2.x, all the tests are passing. I opened a PR to allow numpy 2.x installation: https://github.com/langchain-ai/langchain-postgres/pull/208
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#73