psycopg module version error #36

Closed
opened 2026-02-16 05:16:11 -05:00 by yindo · 1 comment
Owner

Originally created by @erangalds on GitHub (Jul 26, 2024).

I was trying out langchain_postgres module today. I was using the PostgresChatMessageHistory function. I started to get below error when I used the example code given in the README file.

Traceback (most recent call last):
File "/home/eranga/learn/learn-langgraph/brandon-labs/chat_models/02_chat_model_conversation_bot.py", line 44, in
PostgresChatMessageHistory.create_tables(sync_connection, chat_history_table_name)
File "/home/eranga/learn/learn-langgraph/langgraph-env/lib/python3.12/site-packages/langchain_postgres/chat_message_histories.py", line 218, in create_tables
cursor.execute(query)
TypeError: argument 1 must be a string or unicode object: got Composed instead

Then I looked at the modules which threw the error. It was basically saying the cursor.execute(qurey) was expecting a string. Then I looked at the module functions then noticed that the imported library was psycopg. Then I manually changed that to psycopg2. Then the program worked as expected.

Originally created by @erangalds on GitHub (Jul 26, 2024). I was trying out langchain_postgres module today. I was using the PostgresChatMessageHistory function. I started to get below error when I used the example code given in the README file. Traceback (most recent call last): File "/home/eranga/learn/learn-langgraph/brandon-labs/chat_models/02_chat_model_conversation_bot.py", line 44, in <module> PostgresChatMessageHistory.create_tables(sync_connection, chat_history_table_name) File "/home/eranga/learn/learn-langgraph/langgraph-env/lib/python3.12/site-packages/langchain_postgres/chat_message_histories.py", line 218, in create_tables cursor.execute(query) TypeError: argument 1 must be a string or unicode object: got Composed instead Then I looked at the modules which threw the error. It was basically saying the cursor.execute(qurey) was expecting a string. Then I looked at the module functions then noticed that the imported library was psycopg. Then I manually changed that to psycopg2. Then the program worked as expected.
yindo closed this issue 2026-02-16 05:16:11 -05:00
Author
Owner

@eyurtsev commented on GitHub (Jul 26, 2024):

The library is only compatible with psycogp3 (which uses the psycopg namespace). psycopg2 is not supported.

@eyurtsev commented on GitHub (Jul 26, 2024): The library is only compatible with psycogp3 (which uses the psycopg namespace). psycopg2 is not supported.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#36