服务器信息
gcc和centos版本
![9b62553fd76bebd6f41232bc46943102.png](https://i-blog.csdnimg.cn/blog_migrate/ba66f30e46b96b5df6cf35f536a2e0ba.jpeg)
g++
![9b48bfe127901f1e7abc34e905fb4dab.png](https://i-blog.csdnimg.cn/blog_migrate/c70fba14de452ba40601d29ebca9510e.png)
主要报错信息
File "/root/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/anaconda3/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 78, in run
_build_ext.run(self)
File "/root/anaconda3/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/root/anaconda3/lib/python3.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/tmp/pip-install-zf0wwk3u/fasttext/setup.py", line 146, in build_extensions
opts.append(cpp_flag(self.compiler))
File "/tmp/pip-install-zf0wwk3u/fasttext/setup.py", line 109, in cpp_flag
'Unsupported compiler -- at least C++0x support '
RuntimeError: Unsupported compiler -- at least C++0x support is needed!
----------------------------------------
ERROR: Failed building wheel for fasttext
Running setup.py clean for fasttext
Building wheel for JPype1 (setup.py) ... error
问题分析
RuntimeError: Unsupported compiler -- at least C++0x support is needed!是关键错误信息,说是编译器版本至少是C++0x
查看fasttext官网要求是
facebookresearch/fastTextgithub.com![d837bc99558e1bd6c0b7e7ee5231158e.png](https://i-blog.csdnimg.cn/blog_migrate/a2b22a747ee6498301a98e136cd0bada.jpeg)
Generally, fastText builds on modern Mac OS and Linux distributions. Since it uses some C++11 features, it requires a compiler with good C++11 support. These include :
- (g++-4.7.2 or newer) or (clang-3.3 or newer)
那问题比较明显了,是本地没有g++的原因导致的。
命令行安装yum install gcc-c++。
安装成功后查看版本,满足指定要求
![33f55c2edc6f0488bfe323bab041915c.png](https://i-blog.csdnimg.cn/blog_migrate/79c77512961183dd5c8e79dd46a1a3f3.png)
再安装fasttext顺利完成。
差点走的弯路
刚开始安装失败第一反应是搜索一下错误信息看其他人怎么解决的,大部分都是gcc版本太低重新安装gcc的方案,幸好看了下自己gcc版本和g++情况,发现跟其他人问题不一样,再去官网看环境配置要求,发现问题所在是g++本地没有,于是问题解决
总结
可以参考网络其他人问题解决方式,但是前提是自己问题与其他人问题一样,如果不一样就照搬方案只会走弯路,那这里的关键就是定位问题,发现问题的瓶颈在那里,这个是第一步也是最重要的一步。Unsupported compiler -- at least C++0x support是说编译器版本不支持,那编译器其实有c编译器和c++编译器,对应的分别是gcc和g++,而这里出问题的是c++编译器,那问题就定位到了,再去fasttext的官网看具体要求,把不符合的要求解决掉问题也就解决了