尝试安装bertopic,但是Winerror2

问题描述 投票:0回答:1

我正在尝试使用 pip 在 VScode 中安装 bertopic,并且我正在使用虚拟环境,但在构建句子时遇到 Winerror2。

我尝试单独安装sentpiece,但出现了同样的错误。

我使用的是python版本3.12.0和pip版本23.3.2

 PS C:\Users\\Desktop\BA> pip install bertopic
Collecting bertopic
  Using cached bertopic-0.16.0-py2.py3-none-any.whl.metadata (21 kB)
Requirement already satisfied: numpy>=1.20.0 in c:\users\\desktop\ba\.venv\lib\site-packages (from bertopic) (1.26.3)
Collecting hdbscan>=0.8.29 (from bertopic)
  Using cached hdbscan-0.8.33.tar.gz (5.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting umap-learn>=0.5.0 (from bertopic)
  Using cached umap-learn-0.5.5.tar.gz (90 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: pandas>=1.1.5 in c:\users\\desktop\ba\.venv\lib\site-packages (from bertopic) (2.2.0)
Collecting scikit-learn>=0.22.2.post1 (from bertopic)
  Using cached scikit_learn-1.4.0-1-cp312-cp312-win_amd64.whl.metadata (11 kB)
Collecting tqdm>=4.41.1 (from bertopic)
  Using cached tqdm-4.66.1-py3-none-any.whl.metadata (57 kB)
Collecting sentence-transformers>=0.4.1 (from bertopic)
  Using cached sentence_transformers-2.3.1-py3-none-any.whl.metadata (11 kB)
Collecting plotly>=4.7.0 (from bertopic)
  Using cached plotly-5.18.0-py3-none-any.whl.metadata (7.0 kB)
Collecting cython<3,>=0.27 (from hdbscan>=0.8.29->bertopic)
  Using cached Cython-0.29.37-py2.py3-none-any.whl.metadata (3.1 kB)
Collecting scipy>=1.0 (from hdbscan>=0.8.29->bertopic)
  Using cached scipy-1.12.0-cp312-cp312-win_amd64.whl.metadata (60 kB)
Collecting joblib>=1.0 (from hdbscan>=0.8.29->bertopic)
  Using cached joblib-1.3.2-py3-none-any.whl.metadata (5.4 kB)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\\desktop\ba\.venv\lib\site-packages (from pandas>=1.1.5->bertopic) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\\desktop\ba\.venv\lib\site-packages (from pandas>=1.1.5->bertopic) (2023.4)
Requirement already satisfied: tzdata>=2022.7 in c:\users\\desktop\ba\.venv\lib\site-packages (from pandas>=1.1.5->bertopic) (2023.4)
Collecting tenacity>=6.2.0 (from plotly>=4.7.0->bertopic)
  Using cached tenacity-8.2.3-py3-none-any.whl.metadata (1.0 kB)
Requirement already satisfied: packaging in c:\users\\desktop\ba\.venv\lib\site-packages (from plotly>=4.7.0->bertopic) (23.2)
Collecting threadpoolctl>=2.0.0 (from scikit-learn>=0.22.2.post1->bertopic)
  Using cached threadpoolctl-3.2.0-py3-none-any.whl.metadata (10.0 kB)
Collecting transformers<5.0.0,>=4.32.0 (from sentence-transformers>=0.4.1->bertopic)
  Using cached transformers-4.37.2-py3-none-any.whl.metadata (129 kB)
Collecting torch>=1.11.0 (from sentence-transformers>=0.4.1->bertopic)
  Using cached torch-2.2.0-cp312-cp312-win_amd64.whl.metadata (26 kB)
Collecting nltk (from sentence-transformers>=0.4.1->bertopic)
  Using cached nltk-3.8.1-py3-none-any.whl (1.5 MB)
Collecting sentencepiece (from sentence-transformers>=0.4.1->bertopic)
  Using cached sentencepiece-0.1.99.tar.gz (2.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      Traceback (most recent call last):
        File "c:\Users\\Desktop\BA\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "c:\Users\\Desktop\BA\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "c:\Users\\Desktop\BA\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\\AppData\Local\Temp\pip-build-env-s2c75s0u\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\\AppData\Local\Temp\pip-build-env-s2c75s0u\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\\AppData\Local\Temp\pip-build-env-s2c75s0u\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "C:\Users\\AppData\Local\Temp\pip-build-env-s2c75s0u\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 126, in <module>
        File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 408, in check_call      
          retcode = call(*popenargs, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 389, in call
          with Popen(*popenargs, **kwargs) as p:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__       
          self._execute_child(args, executable, preexec_fn, close_fds,
        File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child 
          hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [WinError 2] The system cannot find the file specified
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

我也可以下载其他库,但只有 bertopic 时才会出现错误。

python bert-language-model sentencepiece
1个回答
0
投票

考虑降级你的Python版本,一些库与python 3.12不完全兼容。

如果您使用conda,您可以使用特定版本的Python创建conda环境:

conda create --name myenv python=3.11

激活虚拟环境:

conda activate myenv

您可以使用

pip
来安装
bertopic
:

pip install bertopic
© www.soinside.com 2019 - 2024. All rights reserved.