在Anaconda中安装fasttext
我在使用 Anaconda3-2024.02-1-Windows-x86_64(是的,Windows 64位)在 Windows 11 上,Python 版本是 3.11.7。我想做一个离线翻译器,但我忘了是怎么开始的……最后我尝试安装 EasyNMT,但因为 fasttext 这个包出错了。于是,我决定单独安装 fasttext,但也失败了,搞不清楚问题出在哪里。我在 Anaconda 提示符下用 pip 安装几乎所有的包。而且我的网络连接很差。下面是代码:
(base) C:\Users\pc>pip install wheel
Collecting fasttext
Using cached fasttext-0.9.2.tar.gz (68 kB)
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
╰─> [28 lines of output]
C:\Users\pc\anaconda3\python.exe: No module named pip
Traceback (most recent call last):
File "<string>", line 38, in __init__
ModuleNotFoundError: No module named 'pybind11'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\pc\anaconda3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\pc\anaconda3\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\pc\anaconda3\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\pc\AppData\Local\Temp\pip-build-env-31ahp4pz\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\pc\AppData\Local\Temp\pip-build-env-31ahp4pz\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "C:\Users\pc\AppData\Local\Temp\pip-build-env-31ahp4pz\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "C:\Users\pc\AppData\Local\Temp\pip-build-env-31ahp4pz\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 72, in <module>
File "<string>", line 41, in __init__
RuntimeError: pybind11 install failed.
[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.
note: This error originates from a subprocess, and is likely not a problem with pip.
我刚刚更新了 Visual Studio 的 MS Build Tools,因为我在做另一个项目。我尝试单独安装 pybind11,估计它已经下载好了。
pip install pybind11
结果显示:pybind11 已经安装在 c:\users\pc\anaconda3\lib\site-packages (2.11.1)
所以!!!我不知道该怎么办……请帮帮我!!
更新!!
我在下面的回答后重新开始了一切,一切都很顺利,直到我安装 easyNMT 时出现了这个错误信息:
(base) C:\Windows\System32>pip install -U easynmt
Collecting easynmt
Using cached EasyNMT-2.0.2-py3-none-any.whl
Requirement already satisfied: tqdm in c:\users\pc\appdata\roaming\python\python311\site-packages (from easynmt) (4.66.1)
Requirement already satisfied: transformers<5,>=4.4 in c:\users\pc\anaconda3\lib\site-packages (from easynmt) (4.32.1)
Requirement already satisfied: torch>=1.6.0 in c:\users\pc\anaconda3\lib\site-packages (from easynmt) (2.2.1)
Requirement already satisfied: numpy in c:\users\pc\appdata\roaming\python\python311\site-packages (from easynmt) (1.24.2)
Requirement already satisfied: nltk in c:\users\pc\appdata\roaming\python\python311\site-packages (from easynmt) (3.8.1)
Requirement already satisfied: sentencepiece in c:\users\pc\anaconda3\lib\site-packages (from easynmt) (0.2.0)
Collecting fasttext (from easynmt)
Using cached fasttext-0.9.2.tar.gz (68 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: protobuf in c:\users\pc\anaconda3\lib\site-packages (from easynmt) (5.26.0)
Requirement already satisfied: filelock in c:\users\pc\anaconda3\lib\site-packages (from torch>=1.6.0->easynmt) (3.9.0)
Requirement already satisfied: typing-extensions>=4.8.0 in c:\users\pc\anaconda3\lib\site-packages (from torch>=1.6.0->easynmt) (4.10.0)
Requirement already satisfied: sympy in c:\users\pc\anaconda3\lib\site-packages (from torch>=1.6.0->easynmt) (1.11.1)
Requirement already satisfied: networkx in c:\users\pc\anaconda3\lib\site-packages (from torch>=1.6.0->easynmt) (3.1)
Requirement already satisfied: jinja2 in c:\users\pc\anaconda3\lib\site-packages (from torch>=1.6.0->easynmt) (3.1.2)
Requirement already satisfied: fsspec in c:\users\pc\anaconda3\lib\site-packages (from torch>=1.6.0->easynmt) (2023.4.0)
Requirement already satisfied: huggingface-hub<1.0,>=0.15.1 in c:\users\pc\anaconda3\lib\site-packages (from transformers<5,>=4.4->easynmt) (0.15.1)
Requirement already satisfied: packaging>=20.0 in c:\users\pc\anaconda3\lib\site-packages (from transformers<5,>=4.4->easynmt) (23.1)
Requirement already satisfied: pyyaml>=5.1 in c:\users\pc\anaconda3\lib\site-packages (from transformers<5,>=4.4->easynmt) (6.0)
Requirement already satisfied: regex!=2019.12.17 in c:\users\pc\appdata\roaming\python\python311\site-packages (from transformers<5,>=4.4->easynmt) (2023.12.25)
Requirement already satisfied: requests in c:\users\pc\anaconda3\lib\site-packages (from transformers<5,>=4.4->easynmt) (2.31.0)
Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in c:\users\pc\anaconda3\lib\site-packages (from transformers<5,>=4.4->easynmt) (0.13.2)
Requirement already satisfied: safetensors>=0.3.1 in c:\users\pc\anaconda3\lib\site-packages (from transformers<5,>=4.4->easynmt) (0.3.2)
Requirement already satisfied: colorama in c:\users\pc\appdata\roaming\python\python311\site-packages (from tqdm->easynmt) (0.4.6)
Requirement already satisfied: pybind11>=2.2 in c:\users\pc\anaconda3\lib\site-packages (from fasttext->easynmt) (2.11.1)
Requirement already satisfied: setuptools>=0.7.0 in c:\users\pc\anaconda3\lib\site-packages (from fasttext->easynmt) (68.0.0)
Requirement already satisfied: click in c:\users\pc\appdata\roaming\python\python311\site-packages (from nltk->easynmt) (8.1.7)
Requirement already satisfied: joblib in c:\users\pc\appdata\roaming\python\python311\site-packages (from nltk->easynmt) (1.3.2)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\pc\anaconda3\lib\site-packages (from jinja2->torch>=1.6.0->easynmt) (2.1.1)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\pc\anaconda3\lib\site-packages (from requests->transformers<5,>=4.4->easynmt) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in c:\users\pc\anaconda3\lib\site-packages (from requests->transformers<5,>=4.4->easynmt) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\pc\anaconda3\lib\site-packages (from requests->transformers<5,>=4.4->easynmt) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\pc\anaconda3\lib\site-packages (from requests->transformers<5,>=4.4->easynmt) (2024.2.2)
Requirement already satisfied: mpmath>=0.19 in c:\users\pc\anaconda3\lib\site-packages (from sympy->torch>=1.6.0->easynmt) (1.3.0)
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
╰─> [75 lines of output]
C:\Users\pc\anaconda3\Lib\site-packages\setuptools\dist.py:745: SetuptoolsDeprecationWarning: Invalid dash-separated options
!!
********************************************************************************
Usage of dash-separated 'description-file' will not be supported in future
versions. Please use the underscore name 'description_file' instead.
This deprecation is overdue, please update your project and remove deprecated
calls to avoid build errors in the future.
See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
********************************************************************************
!!
opt = self.warn_dash_deprecation(opt, section)
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\fasttext
copying python\fasttext_module\fasttext\FastText.py -> build\lib.win-amd64-cpython-311\fasttext
copying python\fasttext_module\fasttext\__init__.py -> build\lib.win-amd64-cpython-311\fasttext
creating build\lib.win-amd64-cpython-311\fasttext\util
copying python\fasttext_module\fasttext\util\util.py -> build\lib.win-amd64-cpython-311\fasttext\util
copying python\fasttext_module\fasttext\util\__init__.py -> build\lib.win-amd64-cpython-311\fasttext\util
creating build\lib.win-amd64-cpython-311\fasttext\tests
copying python\fasttext_module\fasttext\tests\test_configurations.py -> build\lib.win-amd64-cpython-311\fasttext\tests
copying python\fasttext_module\fasttext\tests\test_script.py -> build\lib.win-amd64-cpython-311\fasttext\tests
copying python\fasttext_module\fasttext\tests\__init__.py -> build\lib.win-amd64-cpython-311\fasttext\tests
running build_ext
building 'fasttext_pybind' extension
creating build\temp.win-amd64-cpython-311
creating build\temp.win-amd64-cpython-311\Release
creating build\temp.win-amd64-cpython-311\Release\python
creating build\temp.win-amd64-cpython-311\Release\python\fasttext_module
creating build\temp.win-amd64-cpython-311\Release\python\fasttext_module\fasttext
creating build\temp.win-amd64-cpython-311\Release\python\fasttext_module\fasttext\pybind
creating build\temp.win-amd64-cpython-311\Release\src
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\pc\anaconda3\Lib\site-packages\pybind11\include -IC:\Users\pc\anaconda3\Lib\site-packages\pybind11\include -Isrc -IC:\Users\pc\anaconda3\include -IC:\Users\pc\anaconda3\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /EHsc /Tppython/fasttext_module/fasttext/pybind/fasttext_pybind.cc /Fobuild\temp.win-amd64-cpython-311\Release\python/fasttext_module/fasttext/pybind/fasttext_pybind.obj /EHsc /DVERSION_INFO=\\\"0.9.2\\\"
fasttext_pybind.cc
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): error C2065: 'ssize_t': undeclared identifier
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): error C2672: 'pybind11::init': no matching overloaded function found
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1932): note: could be 'Ret pybind11::init(CFunc &&,AFunc &&)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): note: 'pybind11::init': invalid template argument for 'CFunc', type expected
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1924): note: or 'Ret pybind11::init(Func &&)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): note: 'pybind11::init': invalid template argument for 'Func', type expected
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1912): note: or 'pybind11::detail::initimpl::constructor<Args...> pybind11::init(void)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): note: 'pybind11::init': invalid template argument for 'Args', type expected
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): error C2672: 'pybind11::class_<fasttext::Vector>::def': no matching overloaded function found
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1631): note: could be 'pybind11::class_<fasttext::Vector> &pybind11::class_<fasttext::Vector>::def(pybind11::detail::initimpl::pickle_factory<Args...> &&,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1625): note: or 'pybind11::class_<fasttext::Vector> &pybind11::class_<fasttext::Vector>::def(pybind11::detail::initimpl::factory<Args...> &&,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1618): note: or 'pybind11::class_<fasttext::Vector> &pybind11::class_<fasttext::Vector>::def(const pybind11::detail::initimpl::alias_constructor<Args...> &,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1611): note: or 'pybind11::class_<fasttext::Vector> &pybind11::class_<fasttext::Vector>::def(const pybind11::detail::initimpl::constructor<Args...> &,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1599): note: or 'pybind11::class_<fasttext::Vector> &pybind11::class_<fasttext::Vector>::def(const T &,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1574): note: or 'pybind11::class_<fasttext::Vector> &pybind11::class_<fasttext::Vector>::def(const char *,Func &&,const Extra &...)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): note: 'pybind11::class_<fasttext::Vector> &pybind11::class_<fasttext::Vector>::def(const char *,Func &&,const Extra &...)': expects 3 arguments - 1 provided
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2065: 'ssize_t': undeclared identifier
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2065: 'ssize_t': undeclared identifier
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2672: 'pybind11::init': no matching overloaded function found
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1932): note: could be 'Ret pybind11::init(CFunc &&,AFunc &&)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): note: 'pybind11::init': invalid template argument for 'CFunc', type expected
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1924): note: or 'Ret pybind11::init(Func &&)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): note: 'pybind11::init': invalid template argument for 'Func', type expected
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1912): note: or 'pybind11::detail::initimpl::constructor<Args...> pybind11::init(void)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): note: 'pybind11::init': invalid template argument for 'Args', type expected
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2672: 'pybind11::class_<fasttext::DenseMatrix>::def': no matching overloaded function found
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1631): note: could be 'pybind11::class_<fasttext::DenseMatrix> &pybind11::class_<fasttext::DenseMatrix>::def(pybind11::detail::initimpl::pickle_factory<Args...> &&,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1625): note: or 'pybind11::class_<fasttext::DenseMatrix> &pybind11::class_<fasttext::DenseMatrix>::def(pybind11::detail::initimpl::factory<Args...> &&,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1618): note: or 'pybind11::class_<fasttext::DenseMatrix> &pybind11::class_<fasttext::DenseMatrix>::def(const pybind11::detail::initimpl::alias_constructor<Args...> &,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1611): note: or 'pybind11::class_<fasttext::DenseMatrix> &pybind11::class_<fasttext::DenseMatrix>::def(const pybind11::detail::initimpl::constructor<Args...> &,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1599): note: or 'pybind11::class_<fasttext::DenseMatrix> &pybind11::class_<fasttext::DenseMatrix>::def(const T &,const Extra &...)'
C:\Users\pc\anaconda3\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1574): note: or 'pybind11::class_<fasttext::DenseMatrix> &pybind11::class_<fasttext::DenseMatrix>::def(const char *,Func &&,const Extra &...)'
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): note: 'pybind11::class_<fasttext::DenseMatrix> &pybind11::class_<fasttext::DenseMatrix>::def(const char *,Func &&,const Extra &...)': expects 3 arguments - 1 provided
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[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
ERROR: Could not build wheels for fasttext, which is required to install pyproject.toml-based projects
1 个回答
当事情变得这么糟糕时——安装失败,可能是因为之前的一些选择(或者一些没注意到的错误)让人记不清楚了——最好是从头开始,在一个干净的环境中重新来过。
然后,逐步添加需要的东西,按照一定的顺序进行,仔细观察(记笔记)出现问题的第一迹象,或者哪些具体的、最少的步骤是有效的。
如果你在使用Anaconda,你可能可以使用'conda'这个工具来管理不同的“虚拟环境”,每个环境都有自己特定选择的安装包。利用这个工具创建一个新的环境,激活这个环境,然后一步一步地安装你需要的东西。
如果这个过程出现错误,至少你会有更准确的信息来描述你是如何遇到这个错误的——这可以帮助你在StackOverflow上提问,可能会得到更具体的解决方案。