pythonmacosscipygensimopenblas

Python error trying to install gensim on MacOS


trying to install gensim on MacBook Pro (i7, Sonoma 14.7.1) using PyCharm (Python@3.13). I've tried several suggestions from stack, github and other sources but none worked.

Based on what little I found online, it seems that it cannot find openblas, even though it is installed. But it is installed and openBLAS. Is this just a strict case sensitivity or something else?

How do I resolve this? Also, when I try to open the full log, path to file does not exist.

Here is the output in the PyCharm Console:

pip install --upgrade gensim        
Collecting gensim
  Using cached gensim-4.3.3.tar.gz (23.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy<2.0,>=1.18.5 (from gensim)
  Using cached numpy-1.26.4.tar.gz (15.8 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting scipy<1.14.0,>=1.7.0 (from gensim)
  Using cached scipy-1.13.1.tar.gz (57.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [45 lines of output]
      + meson setup /private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-install-ox0sfkbg/scipy_7a9a4932c4254c9d93723beb50b0e629 /private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-install-ox0sfkbg/scipy_7a9a4932c4254c9d93723beb50b0e629/.mesonpy-ry56tq_q -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-install-ox0sfkbg/scipy_7a9a4932c4254c9d93723beb50b0e629/.mesonpy-ry56tq_q/meson-python-native-file.ini
      The Meson build system
      Version: 1.6.0
      Source dir: /private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-install-ox0sfkbg/scipy_7a9a4932c4254c9d93723beb50b0e629
      Build dir: /private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-install-ox0sfkbg/scipy_7a9a4932c4254c9d93723beb50b0e629/.mesonpy-ry56tq_q
      Build type: native build
      Project name: scipy
      Project version: 1.13.1
      C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.4)")
      C linker for the host machine: cc ld64 1115.7.3
      C++ compiler for the host machine: c++ (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.4)")
      C++ linker for the host machine: c++ ld64 1115.7.3
      Cython compiler for the host machine: cython (cython 3.0.11)
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Program python found: YES (/Users/xxxxxxxxxxxx/PycharmProjects/pythonProjectTrainingList/.venv/bin/python)
      Found pkg-config: YES (/usr/local/bin/pkg-config) 2.3.0
      Run-time dependency python found: YES 3.13
      Program cython found: YES (/private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-build-env-9qebkipc/overlay/bin/cython)
      Compiler for C supports arguments -Wno-unused-but-set-variable: YES
      Compiler for C supports arguments -Wno-unused-function: YES
      Compiler for C supports arguments -Wno-conversion: YES
      Compiler for C supports arguments -Wno-misleading-indentation: YES
      Library m found: YES
      Fortran compiler for the host machine: gfortran (gcc 14.2.0 "GNU Fortran (Homebrew GCC 14.2.0_1) 14.2.0")
      Fortran linker for the host machine: gfortran ld64 1115.7.3
      Compiler for Fortran supports arguments -Wno-conversion: YES
      Compiler for C supports link arguments -Wl,-ld_classic: YES
      Checking if "-Wl,--version-script" : links: NO
      Program pythran found: YES 0.15.0 0.15.0 (/private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-build-env-9qebkipc/overlay/bin/pythran)
      Did not find CMake 'cmake'
      Found CMake: NO
      Run-time dependency xsimd found: NO (tried pkgconfig, framework and cmake)
      Run-time dependency threads found: YES
      Library npymath found: YES
      Library npyrandom found: YES
      pybind11-config found: YES (/private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-build-env-9qebkipc/overlay/bin/pybind11-config) 2.12.1
      Run-time dependency pybind11 found: YES 2.12.1
      Run-time dependency scipy-openblas found: NO (tried pkgconfig)
      Run-time dependency openblas found: NO (tried pkgconfig, framework and cmake)
      Run-time dependency openblas found: NO (tried pkgconfig and framework)
      
      ../scipy/meson.build:163:9: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig and framework
      
      A full log can be found at /private/var/folders/92/9fd9rgg976s7zn44fvbxjw000000gn/T/pip-install-ox0sfkbg/scipy_7a9a4932c4254c9d93723beb50b0e629/.mesonpy-ry56tq_q/meson-logs/meson-log.txt
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Solution

  • Gensim has precompiled wheels up to Python 3.12.

    Your easiest resolution is to downgrade Python from 3.13 to 3.12, so you can use one of those precompiled wheels (gensim-4.3.3-cp312-cp312-macosx_11_0_arm64.whl; that's a detail you don't need to care about; pip install will choose that wheel when compatible), so you don't need to have an environment in which you can compile Gensim from source.

    You might also want to raise an issue on Gensim's GitHub so there'd be wheels for 3.13 in the future.