解决PyStemmer项目在构建安装轮时出现的错误:pyproject.toml配置问题指南

问题描述

安装fastembed包的时候发现在PyStemmer这一步的时候报错:

Building wheels for collected packages: PyStemmer
  Building wheel for PyStemmer (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      D:\anaconda\envs\patient\lib\site-packages\setuptools\__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
      running bdist_wheel
      running build
      running build_ext
      cythoning src/Stemmer.pyx to src\Stemmer.c
      c:\users\niede\appdata\local\temp\pip-install-2e_dgeos\pystemmer_8047ca4648ab4e29ab2e31422b306fc5\.eggs\cython-0.29.37-py3.9.egg\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\niede\AppData\Local\Temp\pip-install-2e_dgeos\pystemmer_8047ca4648ab4e29ab2e31422b306fc5\src\Stemmer.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      building 'Stemmer' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyStemmer
  Running setup.py clean for PyStemmer
Failed to build PyStemmer
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (PyStemmer)

(patient) E:\AI_Patient-master\my_base_images>pip install PyStemmer==2.2.0
Collecting PyStemmer==2.2.0
  Downloading PyStemmer-2.2.0.tar.gz (698 kB)
     ---------------------------------------- 698.7/698.7 kB 29.1 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [10 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\niede\AppData\Local\Temp\pip-install-nhcfl0jw\pystemmer_6348aa74633142a0a7f53cc08836c65d\setup.py", line 199, in <module>
          ['src/Stemmer.pyx'] + list(LIBRARY_SOURCE_CODE.source_code_paths()),
        File "C:\Users\niede\AppData\Local\Temp\pip-install-nhcfl0jw\pystemmer_6348aa74633142a0a7f53cc08836c65d\setup.py", line 85, in source_code_paths
          for line in self.iter_manifest_lines():
        File "C:\Users\niede\AppData\Local\Temp\pip-install-nhcfl0jw\pystemmer_6348aa74633142a0a7f53cc08836c65d\setup.py", line 74, in iter_manifest_lines
          with open(self.manifest_file_path) as file:
      FileNotFoundError: [Errno 2] No such file or directory: 'libstemmer_c-2.2.0\\mkinc_utf8.mak'
      [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.

(patient) E:\AI_Patient-master\my_base_images>pip install wheel
Requirement already satisfied: wheel in d:\anaconda\envs\patient\lib\site-packages (0.44.0)

(patient) E:\AI_Patient-master\my_base_images>pip install PyStemmer==2.1.0
ERROR: Could not find a version that satisfies the requirement PyStemmer==2.1.0 (from versions: 1.1.0, 1.2.0, 1.3.0, 2.0.0, 2.0.0.1, 2.0.1, 2.2.0, 2.2.0.1)
ERROR: No matching distribution found for PyStemmer==2.1.0

(patient) E:\AI_Patient-master\my_base_images>pip install PyStemmer==2.2.0.1
Collecting PyStemmer==2.2.0.1
  Using cached PyStemmer-2.2.0.1.tar.gz (303 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: PyStemmer
  Building wheel for PyStemmer (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      D:\anaconda\envs\patient\lib\site-packages\setuptools\__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
      running bdist_wheel
      running build
      running build_ext
      cythoning src/Stemmer.pyx to src\Stemmer.c
      c:\users\niede\appdata\local\temp\pip-install-t5k_cnlf\pystemmer_5465a1e7a6734cdcb0bec422fa83ffe5\.eggs\cython-0.29.37-py3.9.egg\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\niede\AppData\Local\Temp\pip-install-t5k_cnlf\pystemmer_5465a1e7a6734cdcb0bec422fa83ffe5\src\Stemmer.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      building 'Stemmer' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyStemmer
  Running setup.py clean for PyStemmer
Failed to build PyStemmer
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (PyStemmer)

解决方案:

打开网址如下:

https://pypi.org/

在搜索框里搜PyStemmer,看到最新的安装包是这个:

点进去download file之后解压出来一个文件夹如下:

进入conda环境,输入以下两行命令:

python setup.py build
python setup.py install

这个时候可能会报错:

(patient) E:\PyStemmer-2.2.0.1>python setup.py build
Downloading https://snowballstem.org/dist/libstemmer_c-2.2.0.tar.gz... DONE
Checking that SHA256 of libstemmer_c-2.2.0.tar.gz is b941d9fe9cf36b4e2f8d3873cd4d8b8775bd94867a1df8d8c001bb8b688377c3... SHA256 is b941d9fe9cf36b4e2f8d3873cd4d8b8775bd94867a1df8d8c001bb8b688377c3. OK
Extracting libstemmer_c-2.2.0.tar.gz... DONE
D:\anaconda\envs\patient\lib\site-packages\setuptools\__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
running build
running build_ext
cythoning src/Stemmer.pyx to src\Stemmer.c
e:\pystemmer-2.2.0.1\.eggs\cython-0.29.37-py3.9.egg\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: E:\PyStemmer-2.2.0.1\src\Stemmer.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
building 'Stemmer' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

(patient) E:\PyStemmer-2.2.0.1>python setup.py install
D:\anaconda\envs\patient\lib\site-packages\setuptools\__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
running install
D:\anaconda\envs\patient\lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
D:\anaconda\envs\patient\lib\site-packages\setuptools\_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  self.initialize_options()
running bdist_egg
running egg_info
writing PyStemmer.egg-info\PKG-INFO
writing dependency_links to PyStemmer.egg-info\dependency_links.txt
writing top-level names to PyStemmer.egg-info\top_level.txt
reading manifest file 'PyStemmer.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
adding license file 'AUTHORS'
writing manifest file 'PyStemmer.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_ext
skipping 'src\Stemmer.c' Cython extension (up-to-date)
building 'Stemmer' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

这里解决error: Microsoft Visual C++ 14.0 or greater is required.的方法可以参考
https://blog.csdn.net/qq_40298645/article/details/136621656中提到的第三种方法(亲测人在国外第二种方法也没用,还是老老实实离线安装,两分钟就全部装完了)

之后运行上面两行命令就可以成功,最后运行pip install fastembed即可

作者:怎么有人也叫九十九由基

物联沃分享整理
物联沃-IOTWORD物联网 » 解决PyStemmer项目在构建安装轮时出现的错误:pyproject.toml配置问题指南

发表回复