问题
I tried to install crf++ in my macbook. I downloaded CRF++-0.58 from https://taku910.github.io/crfpp/#download. Then I followed the instructins on the official website of crf++.
I firstly entered the folder named CRF++-0.58. Then I typed following code in terminal:
make
sudo make install
cd python
These commands run well. Then I typed
python setup.py install
The output was as following:
running build
running build_py
running build_ext
building '_CRFPP' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -I/anaconda3/include/python3.7m -c CRFPP_wrap.cxx -o build/temp.macosx-10.7-x86_64-3.7/CRFPP_wrap.o
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on
the command line to use the libc++ standard library instead
[-Wstdlibcxx-not-found]
CRFPP_wrap.cxx:2375:23: warning: explicitly assigning value of variable of type
'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
CRFPP_wrap.cxx:2378:23: warning: explicitly assigning value of variable of type
'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
CRFPP_wrap.cxx:2900:9: warning: variable 'res' is used uninitialized whenever
'if' condition is true [-Wsometimes-uninitialized]
if (PyType_Ready(tp) < 0)
^~~~~~~~~~~~~~~~~~~~
CRFPP_wrap.cxx:2924:10: note: uninitialized use occurs here
return res;
^~~
CRFPP_wrap.cxx:2900:5: note: remove the 'if' if its condition is always false
if (PyType_Ready(tp) < 0)
^~~~~~~~~~~~~~~~~~~~~~~~~
CRFPP_wrap.cxx:2881:10: note: initialize the variable 'res' to silence this
warning
int res;
^
= 0
CRFPP_wrap.cxx:2981:10: fatal error: 'stdexcept' file not found
#include <stdexcept>
^~~~~~~~~~~
4 warnings and 1 error generated.
error: command 'gcc' failed with exit status 1
Then I searched the error "error: command 'gcc' failed with exit status 1" online. And I found people who had similar problems. I tried some of their solutions but none of them worked.
I tried to install python-dev to solve this problem but failed.
(base) localhost:python dxm$ brew install python3-dev
Error: No available formula with the name "python3-dev"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...`enter code here`
==> Searching taps on GitHub...
Error: No formulae found in taps.
So how could I solve this problem?
回答1:
I found apple gave a way to install crf++ which seems totally different with what I tried: http://macappstore.org/crf/
After installing by this way, I can use crf++ like this:
crf_train = "crf_learn -f 3 template.txt dg_train.txt dg_model"
os.system(crf_train)
crf_test = "crf_test -m dg_model dg_test.txt -o dg_result.txt"
os.system(crf_test)
来源:https://stackoverflow.com/questions/57156374/error-command-gcc-failed-with-exit-status-1-while-installing-crf