langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
28.83k stars 3.69k forks source link

langflow doesnt run on mac os monterey #3819

Closed jtoy closed 1 day ago

jtoy commented 2 days ago

Bug Description

I installed with pip on mac os monterey on an m1 then ran this command and it just hangs: python3 -m langflow run --dev --log-level debug [09/15/24 19:11:58] DEBUG 2024-09-15 19:11:58 - DEBUG - logger - Logger set up with log level: debug logger.py:208 DEBUG 2024-09-15 19:11:58 - DEBUG - main - Set OBJC_DISABLE_INITIALIZE_FORK_SAFETY to YES to avoid error main.py:78 DEBUG 2024-09-15 19:11:58 - DEBUG - manager - Create service settings_service manager.py:65 DEBUG 2024-09-15 19:11:58 - DEBUG - base - No database_url provided, trying LANGFLOW_DATABASE_URL env variable base.py:206 DEBUG 2024-09-15 19:11:58 - DEBUG - base - No database_url env variable, using sqlite database base.py:211 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Saving database to langflow directory: base.py:229 /Users/jtoy/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/langflow
DEBUG 2024-09-15 19:11:58 - DEBUG - base - Setting default components path to components_path base.py:293 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Components path: base.py:298 ['/Users/jtoy/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/langflow/components']
DEBUG 2024-09-15 19:11:58 - DEBUG - base - Setting user agent to langflow base.py:175 DEBUG 2024-09-15 19:11:58 - DEBUG - auth - No secret key provided, generating a random one auth.py:98 DEBUG 2024-09-15 19:11:58 - DEBUG - auth - Loaded secret key auth.py:102 DEBUG 2024-09-15 19:11:58 - DEBUG - auth - Resetting superuser password to default value auth.py:76 DEBUG 2024-09-15 19:11:58 - DEBUG - util - Adding component path util.py:452 /Users/jtoy/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/langflow/components
DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updating settings base.py:309 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updating components_path base.py:315 DEBUG 2024-09-15 19:11:58 - DEBUG - base - components_path: base.py:337 ['/Users/jtoy/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/langflow/components']
DEBUG 2024-09-15 19:11:58 - DEBUG - util - Setting auto_saving_interval to 1000 util.py:461 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updating settings base.py:309 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updating auto_saving_interval base.py:315 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updated auto_saving_interval base.py:336 DEBUG 2024-09-15 19:11:58 - DEBUG - base - auto_saving_interval: 1000 base.py:337 DEBUG 2024-09-15 19:11:58 - DEBUG - util - Setting health_check_max_retries to True util.py:464 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updating settings base.py:309 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updating health_check_max_retries base.py:315 DEBUG 2024-09-15 19:11:58 - DEBUG - base - Updated health_check_max_retries base.py:336 DEBUG 2024-09-15 19:11:58 - DEBUG - base - health_check_max_retries: 1 base.py:337 INFO 2024-09-15 19:11:58 - INFO - main - Setting up app with static files directory None main.py:226 objc[8631]: +[NSCFConstantString initialize] may have been in progress in another thread when fork() was called. objc[8631]: +[NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

Reproduction

  1. pip install langflow

Expected behavior

  1. web server runs and I can go to the browser
  2. python3 -m langflow run --dev --log-level debug

Who can help?

No response

Operating System

mac os monterey 12.5

Langflow Version

1.0.18

Python Version

None

Screenshot

No response

Flow File

No response

dosubot[bot] commented 2 days ago

Hey @jtoy 👋, I'm here to help with any issues you're experiencing. I can assist with bug fixes, answer questions, and guide you on how to become a contributor.

There are a few similar issues that have been reported and resolved:

  1. Error/Crash running on macOS Apple M1: The suggested solution is to set the environment variable OBJC_DISABLE_INITIALIZE_FORK_SAFETY to YES:

    export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

    This solution has been positively received [1].

  2. Langflow Crashes without any error: This issue is closed but does not provide a specific solution.

  3. Process stuck: The issue was resolved by removing the LANGCHAIN_HANDLER=langchain environment variable, which was blocking the process [2].

In your case, it seems that the OBJC_DISABLE_INITIALIZE_FORK_SAFETY environment variable is already being set, as indicated by the log message:

DEBUG    - __main__ - Set OBJC_DISABLE_INITIALIZE_FORK_SAFETY to YES to avoid error

However, the crash still occurs. This might be due to other factors. Here are a few steps you can try:

  1. Ensure the environment variable is set correctly:

    export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
  2. Check for other environment variables: Ensure that no other environment variables are causing conflicts, such as LANGCHAIN_HANDLER.

  3. Update dependencies: Make sure all dependencies are up to date. Sometimes, issues are resolved in newer versions of libraries.

  4. Run with minimal configuration: Try running Langflow with minimal configuration to isolate the issue.

If the problem persists, you might want to look into the specific configurations and setups required for the SQLite database used by Langflow, as defined in the Settings class within the src/backend/base/langflow/services/settings/base.py file [3][4].

To continue talking to Dosu, mention @dosu.

nicoloboschi commented 1 day ago

@jtoy this is a common c/macos problem, see for example here: https://github.com/rails/rails/issues/38560

please set OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES before running langflow in your terminal