0

I have been trying to install the "FastText" library on macOS but I keep encountering a Runtime error.

System - MacOS: 13.0.1 (22A400)

Python Version: 3.10

IDE: Pycharm

I tried installing it from Pycharm but it did not work, then i tried using the Terminal and this is what i got.

pip3 install fasttext and sudo pip3 install fasttext

all resulted with the same error below:

  Using cached fasttext-0.9.2.tar.gz (68 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pybind11>=2.2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from fasttext) (2.10.2)
Requirement already satisfied: setuptools>=0.7.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from fasttext) (65.5.0)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from fasttext) (1.21.4)
Building wheels for collected packages: fasttext
  Building wheel for fasttext (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [67 lines of output]
      /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py:771: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.9-universal2-cpython-310
      creating build/lib.macosx-10.9-universal2-cpython-310/fasttext
      copying python/fasttext_module/fasttext/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
      copying python/fasttext_module/fasttext/FastText.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
      creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
      copying python/fasttext_module/fasttext/util/util.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
      copying python/fasttext_module/fasttext/util/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
      creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      copying python/fasttext_module/fasttext/tests/test_script.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      copying python/fasttext_module/fasttext/tests/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      copying python/fasttext_module/fasttext/tests/test_configurations.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      running build_ext
      creating var
      creating var/folders
      creating var/folders/xg
      creating var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn
      creating var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpejxme0zs.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpejxme0zs.o -stdlib=libc++
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpyu7_bprq.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpyu7_bprq.o -stdlib=libc++ -mmacosx-version-min=10.7
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 168, in <module>
          setup(
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
          _build_ext.run(self)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 131, in build_extensions
          raise RuntimeError(
      RuntimeError: libc++ is needed! Failed to compile with -stdlib=libc++ -mmacosx-version-min=10.7 and -stdlib=libc++.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for fasttext
  Running setup.py clean for fasttext
Failed to build fasttext
Installing collected packages: fasttext
  Running setup.py install for fasttext ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for fasttext did not run successfully.
  │ exit code: 1
  ╰─> [66 lines of output]
      /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py:771: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      running install
      /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.9-universal2-cpython-310
      creating build/lib.macosx-10.9-universal2-cpython-310/fasttext
      copying python/fasttext_module/fasttext/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
      copying python/fasttext_module/fasttext/FastText.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
      creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
      copying python/fasttext_module/fasttext/util/util.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
      copying python/fasttext_module/fasttext/util/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
      creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      copying python/fasttext_module/fasttext/tests/test_script.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      copying python/fasttext_module/fasttext/tests/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      copying python/fasttext_module/fasttext/tests/test_configurations.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
      running build_ext
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7pgbysh_.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7pgbysh_.o -stdlib=libc++
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7hnnqnja.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7hnnqnja.o -stdlib=libc++ -mmacosx-version-min=10.7
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 168, in <module>
          setup(
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/install.py", line 68, in run
          return orig.install.run(self)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/install.py", line 698, in run
          self.run_command('build')
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
          _build_ext.run(self)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 131, in build_extensions
          raise RuntimeError(
      RuntimeError: libc++ is needed! Failed to compile with -stdlib=libc++ -mmacosx-version-min=10.7 and -stdlib=libc++.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> fasttext

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure. ```

 


 
2
  • Showing in your question the exact commands you've tried to install, & full errors you've received in response (as quoted text rather than screenshots), can help others see what's going on to help. It's hard to guess which of the many possible installation-instructions you might be following, or guess what precedes a tiny final fragment of a longer error. Commented Dec 31, 2022 at 22:18
  • 1
    @gojomo I have updated my post I hope it can give clarity for the problem Commented Jan 1, 2023 at 8:51

1 Answer 1

0

As an initial observation: it's often a good practice to install the Python libraries you need for a particular development project into a project-specific virtual environment.

That is, you set up a separate and specific Python interpreter, of a version you consciously choose, with its own set of installed libraries, which does not then affect the system's default Python installation in any way. It then becomes easier to choose whatever libraries/versions you need for that project, without any risk of confusing things for other programs on the same system. It also helps enforce a clear declaration of your project's actual prerequisites, so that you can re-create an adequante virtual-environment later when needed in new places – rather than leaving that to the chance/history of what's been globally installed on the devlopment machine.

Either the conda tool or the venv functionality of Python 3 can be used to set up such an environment, and after creation, each time you want to use that specific Python installation, you must activate it – so that in a particular shell, it becomes the active Python.

All that said, the error you're having relates to the lack of needed c++ development tools, which your installation-method seems to require to compile to those non-Python parts of Facebook's FastText library.

A bunch of options you could consider to get around this:

  • installing Apple's full XCode, including C++ & a bunch of other compilation/build tools, might resolve or change your error. There's more discussion from people who've hit a similar error, and eventually gotten around it using XCode-related configuration, at an issue in the Fasttext project: https://github.com/facebookresearch/fastText/issues/753

  • if using conda – I usually start with miniconda per the minimal instructions at https://docs.conda.io/en/latest/miniconda.html – it might be smart enough to choose a package already precompiled properly for your setup, even if you don't have C++ build tools locally. That is, after setting up your desired environment, then activating it, doing a conda install fasttext inside that environment might just work for you, skipping the local compilation error.

  • depending on your fasttext needs, you might also consider using some other Python library with FastText support, like Gensim. It doesn't support -supervised mode, but does support the core word-vectors (and synthesis of out-of-vocabulary word-vectors via character n-grams) capabilities of FastText, with some extra flexibility & related utility functions.

Sign up to request clarification or add additional context in comments.

1 Comment

I appreciate the lengthy comment, I will try these option out.. thanks again :)!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.