You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When installing langflow on a windows environment, if you set the LANGFLOW_DATABASE_URL to a valid and available postgres instance you may encounter the following asyncio related error:
2025-01-28 11:50:30.271 ERROR service.py 155 with_session Database error during session scope: (psycopg.InterfaceError) Psycopg cannot use the 'ProactorEventLoop' to run in async mode. Please use a compatible event loop, for instance by setting 'asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())'
(Background on this error at: https://sqlalche.me/e/20/rvf5)
2025-01-28 11:50:30.273 ERROR utils.py 76 initialize_database Error creating DB and tables
This is due to differences in how the Windows subsystem handles the Event Loop. I have provided the solution in the "Who can help" section below. I am only asking for it to implemented at your earliest convenience.
Reproduction
To reproduce this you must be on Windows (this bug is specific to a Windows environment):
1. Create a python venv: python -m venv ./menv
2. Initialize venv: ./menv/Scripts/activate
3. Install uv: pip install uv
4. Install langflow: uv pip install langflow
5. Edit your environment variables and set your databaseurl to an available postgres instance: "LANGFLOW_DATABASE_URL":"postgresql://username:password@localhost:5432/langflow" (NOTE this is just an example url, modify for your postgres instance)
6. Run langflow: langflow run
Expected behavior
The expected behavior is that Langflow will initialize the database in postgres. Unfortunately because windows might handle async operations different from *nix systems, an additional check and modification is necessary in the services.py file found under services/daatabase folder.
Add the following after the existing imports but before any other code (for me, this was lines 33:36 of the services.py file):
Hey @ebachUTSA! 👋 I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer. I'm an expert bot and I'm at your service!
For the current issue you're facing, the error is related to the event loop policy on Windows. The suggested solution is to modify the services.py file to set the event loop policy for Windows. You can add the following code after the existing imports:
Bug Description
When installing langflow on a windows environment, if you set the LANGFLOW_DATABASE_URL to a valid and available postgres instance you may encounter the following asyncio related error:
This is due to differences in how the Windows subsystem handles the Event Loop. I have provided the solution in the "Who can help" section below. I am only asking for it to implemented at your earliest convenience.
Reproduction
To reproduce this you must be on Windows (this bug is specific to a Windows environment):
Expected behavior
The expected behavior is that Langflow will initialize the database in postgres. Unfortunately because windows might handle async operations different from *nix systems, an additional check and modification is necessary in the services.py file found under services/daatabase folder.
Add the following after the existing imports but before any other code (for me, this was lines 33:36 of the services.py file):
Who can help?
@italojohnny
Operating System
Windows 10
Langflow Version
1.1.2dev3 (langflow nightly)
Python Version
3.12
Screenshot
No response
Flow File
No response
The text was updated successfully, but these errors were encountered: