facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.45k stars 6.4k forks source link

ERROR: Could not build wheels for fairseq which use PEP 517 and cannot be installed directly #2908

Closed sinhzun closed 3 years ago

sinhzun commented 3 years ago

🐛 Bug

I tried to install fairseq by using both pip and installing from source. But the error happen: ERROR: Could not build wheels for fairseq which use PEP 517 and cannot be installed directly

To Reproduce

The full error log is very long, below is some snipset:

` $ pip3 install fairseq Collecting fairseq Using cached fairseq-0.10.0.tar.gz (677 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing wheel metadata ... done Collecting editdistance Using cached editdistance-0.5.3.tar.gz (27 kB) Requirement already satisfied: hydra-core in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (1.0.4) Requirement already satisfied: cython in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (0.29.21) Requirement already satisfied: sacrebleu>=1.4.12 in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (1.4.14) Requirement already satisfied: tqdm in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (4.52.0) Requirement already satisfied: regex in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (2020.11.13) Requirement already satisfied: numpy in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (1.19.2) Requirement already satisfied: torch in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (1.7.0+cpu) Requirement already satisfied: dataclasses in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (0.6) Requirement already satisfied: cffi in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from fairseq) (1.14.3) Requirement already satisfied: antlr4-python3-runtime==4.8 in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from hydra-core->fairseq) (4.8) Requirement already satisfied: importlib-resources; python_version < "3.9" in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from hydra-core->fairseq) (3.3.0) Requirement already satisfied: omegaconf>=2.0.5 in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from hydra-core->fairseq) (2.0.5) Requirement already satisfied: portalocker in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from sacrebleu>=1.4.12->fairseq) (2.0.0) Requirement already satisfied: typing-extensions in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from torch->fairseq) (3.7.4.3) Requirement already satisfied: future in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from torch->fairseq) (0.18.2) Requirement already satisfied: pycparser in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from cffi->fairseq) (2.20) Requirement already satisfied: PyYAML>=5.1.* in /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages (from omegaconf>=2.0.5->hydra-core->fairseq) (5.3.1) Building wheels for collected packages: fairseq, editdistance Building wheel for fairseq (PEP 517) ... error ERROR: Command errored out with exit status 1: command: /home/local/anaconda3/envs/phobert/bin/python /home/local/anaconda3/envs/phobert/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpi0w5grx5 cwd: /tmp/pip-install-1s172n6m/fairseq Complete output (674 lines): running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.8 creating build/lib.linux-x86_64-3.8/fairseq copying fairseq/sequence_generator.py -> build/lib.linux-x86_64-3.8/fairseq copying fairseq/binarizer.py -> build/lib.linux-x86_64-3.8/fairseq .... creating build/temp.linux-x86_64-3.8/fairseq/clib creating build/temp.linux-x86_64-3.8/fairseq/clib/libbleu gcc -pthread -B /home/local/anaconda3/envs/phobert/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/local/anaconda3/envs/phobert/include/python3.8 -c fairseq/clib/libbleu/libbleu.cpp -o build/temp.linux-x86_64-3.8/fairseq/clib/libbleu/libbleu.o -std=c++11 -O3 gcc: error trying to exec 'cc1plus': execvp: No such file or directory error: command 'gcc' failed with exit status 1

ERROR: Failed building wheel for fairseq Building wheel for editdistance (setup.py) ... error ERROR: Command errored out with exit status 1: command: /home/local/anaconda3/envs/phobert/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1s172n6m/editdistance/setup.py'"'"'; file='"'"'/tmp/pip-install-1s172n6m/editdistance/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-qe4g1iqi cwd: /tmp/pip-install-1s172n6m/editdistance/ Complete output (16 lines): running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.8 creating build/lib.linux-x86_64-3.8/editdistance copying editdistance/init.py -> build/lib.linux-x86_64-3.8/editdistance copying editdistance/_editdistance.h -> build/lib.linux-x86_64-3.8/editdistance copying editdistance/def.h -> build/lib.linux-x86_64-3.8/editdistance running build_ext building 'editdistance.bycython' extension creating build/temp.linux-x86_64-3.8 creating build/temp.linux-x86_64-3.8/editdistance gcc -pthread -B /home/local/anaconda3/envs/phobert/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I./editdistance -I/home/local/anaconda3/envs/phobert/include/python3.8 -c editdistance/_editdistance.cpp -o build/temp.linux-x86_64-3.8/editdistance/_editdistance.o gcc: error trying to exec 'cc1plus': execvp: No such file or directory error: command 'gcc' failed with exit status 1

ERROR: Failed building wheel for editdistance Running setup.py clean for editdistance Failed to build fairseq editdistance ERROR: Could not build wheels for fairseq which use PEP 517 and cannot be installed directly `

Environment

myleott commented 3 years ago

Can you try pip install editdistance and see if that works?

myleott commented 3 years ago

editdistance isn't actually a strict requirement btw, it's only required for some of the wav2vec models. You can try removing it from setup.py if necessary.

lcxywfe commented 3 years ago

gcc: error trying to exec 'cc1plus': execvp: No such file or directory try sudo apt install g++

sinhzun commented 3 years ago

pip install editdistance

Thank you guy, this works for my case.

farnazgh commented 1 year ago

You need to upgrade your version of pip before installing the package: pip install --upgrade pip

h93910 commented 1 year ago

You need to upgrade your version of pip before installing the package: pip install --upgrade pip

it is work for me on colab :D

iSHAANphaye commented 1 year ago

Can you try pip install editdistance and see if that works?

That worked like a charm!

EMachin3 commented 1 year ago

Can you try pip install editdistance and see if that works?

certified gamer

craftersshaft commented 1 year ago

neither of these worked, using python 3.10 but it at least gave me this running build_ext building 'fairseq.libbleu' 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/

ghost commented 1 year ago

running build_ext building 'fairseq.libbleu' 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/

install https://visualstudio.microsoft.com/visual-cpp-build-tools/

Nik-Kras commented 6 months ago

I had the same problem, running on Linux server. Whenever I tried to install fairseq I got Failed building wheel for fairseq. Aparently, the problem was in C++ compiler. Follow steps below, if you have Linux, you will just need to install g++:

  1. Install / Update packages sudo apt update && sudo apt install build-essential
  2. Check list of available g++ apt search '^g\+\+-[0-9]+$'
  3. Install at least version 12 or later from the list of available versions sudo apt install g++-12

PS: Here are error logs I used to get before this solution

 pip install fairseq

 ....

gcc -pthread -B /opt/conda/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/include -fPIC -O2 -isystem /opt/conda/include -fPIC -I/opt/conda/include/python3.10 -c fairseq/clib/libbleu/libbleu.cpp -o build/temp.linux-x86_64-cpython-310/fairseq/clib/libbleu/libbleu.o -std=c++11 -O3
      error: command 'gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for fairseq
  Building wheel for antlr4-python3-runtime (setup.py) ... done
  Created wheel for antlr4-python3-runtime: filename=antlr4_python3_runtime-4.8-py3-none-any.whl size=141209 sha256=5f5d56effcc196ca1d5eb3fe94da5ead9ba550f6e5bf9d4f29b7454f624705fe
  Stored in directory: /root/.cache/pip/wheels/a7/20/bd/e1477d664f22d99989fd28ee1a43d6633dddb5cb9e801350d5
Successfully built antlr4-python3-runtime
Failed to build fairseq
ERROR: Could not build wheels for fairseq, which is required to install pyproject.toml-based projects