mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
Incompatible with latest langchain-community version due to numpy dependency
#73
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jKlag on GitHub (Apr 23, 2025).
Originally assigned to: @dishaprakash on GitHub.
After
langchain-community's latest updates to itsnumpydependencies (in release v0.3.22),langchain-postgrescan no longer be installed in the same environment:I believe the numpy dependency in this package (currently
numpy = "^1.21") will need to be updated to something>=2.1.0in order to resolve this issue.@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
my-app/pyproject.toml
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?
@kozlek commented on GitHub (May 7, 2025):
The problem comes mainly from
langchain-community.The last version of
Numpy 1.xwas 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 enforcedNumpy 2.xfor 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:
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):
According to Numpy documentation, there is a
ruffrule that can check if we still use 1.x only functions or constants: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#ruff-pluginAfter 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):
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