Mit*_*ril 4 c++ python linux ubuntu gcc
我想安装一个 auto-sklearn 包,它依赖于pyrfr
.
安装命令是curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install
.
我的环境:ubuntu 12.04,python3.5-dev(在 virtualenv 中),安装了 gcc 4.8 和 g++ 4.8。
\n\n我通过以下方式安装 gcc 和 g++:
\n\nsudo apt-get install python-software-properties\nsudo add-apt-repository ppa:ubuntu-toolchain-r/test\nsudo apt-get update\n\nsudo apt-get install gcc-4.8\nsudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50\n
Run Code Online (Sandbox Code Playgroud)\n\n默认 gcc 设置正确:
\n\n\xe2\x9e\x9c ~ gcc -v\nUsing built-in specs.\nCOLLECT_GCC=gcc\nCOLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper\nTarget: x86_64-linux-gnu\nConfigured with: ../src/configure -v --with-pkgversion=\'Ubuntu 4.8.1-2ubuntu1~12.04\' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu\nThread model: posix\ngcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04)\n
Run Code Online (Sandbox Code Playgroud)\n\n但我发现 python shell 仍然显示[GCC 4.6.3]:
\n\n\xe2\x9e\x9c ~ python\nPython 3.5.2 (default, Jul 17 2016, 17:38:18)\n[GCC 4.6.3] on linux\nType "help", "copyright", "credits" or "license" for more information.\n>>>\n
Run Code Online (Sandbox Code Playgroud)\n\n并安装pyrfr
仍然说(因为需要 gcc 4.7 或更高版本):
cc1plus: error: unrecognized command line option \xe2\x80\x98-std=c++11\xe2\x80\x99\nerror: command \'x86_64-linux-gnu-gcc\' failed with exit status 1\n
Run Code Online (Sandbox Code Playgroud)\n\n更详细的错误日志:
\n\nCollecting pyrfr\n Downloading http://mirrors.aliyun.com/pypi/packages/95/90/95f77f76c2e3d44577ff2b96b0d365429797d9f83632b84d2c91d2b7a73a/pyrfr-0.2.0.tar.gz (340kB)\n 100% |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 348kB 4.9MB/s\nBuilding wheels for collected packages: pyrfr\n Running setup.py bdist_wheel for pyrfr ... error\n Complete output from command /root/.virtualenvs/py35/bin/python3.5 -u -c "import setuptools, tokenize;__file__=\'/tmp/pip-build-wt1wfz_q/pyrfr/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/tmpcdvohh34pip-wheel- --python-tag cp35:\n running bdist_wheel\n running build\n running build_py\n creating build\n creating build/lib.linux-x86_64-3.5\n creating build/lib.linux-x86_64-3.5/pyrfr\n copying pyrfr/__init__.py -> build/lib.linux-x86_64-3.5/pyrfr\n running build_ext\n building \'pyrfr.regression\' extension\n creating build/temp.linux-x86_64-3.5\n creating build/temp.linux-x86_64-3.5/pyrfr\n x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I./include -I/root/.virtualenvs/py35/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/root/.virtualenvs/py35/include/python3.5m -c pyrfr/regression.cpp -o build/temp.linux-x86_64-3.5/pyrfr/regression.o -O2 -std=c++11\n cc1plus: warning: command line option \xe2\x80\x98-Wstrict-prototypes\xe2\x80\x99 is valid for Ada/C/ObjC but not for C++ [enabled by default]\n cc1plus: error: unrecognized command line option \xe2\x80\x98-std=c++11\xe2\x80\x99\n error: command \'x86_64-linux-gnu-gcc\' failed with exit status 1\n\n ----------------------------------------\n Failed building wheel for pyrfr\n Running setup.py clean for pyrfr\nFailed to build pyrfr\nInstalling collected packages: pyrfr\n Running setup.py install for pyrfr ... error\n Complete output from command /root/.virtualenvs/py35/bin/python3.5 -u -c "import setuptools, tokenize;__file__=\'/tmp/pip-build-wt1wfz_q/pyrfr/setup.py\';f=getattr(tokenize, \'open\', open)(__file__);code=f.read().replace(\'\\r\\n\', \'\\n\');f.close();exec(compile(code, __file__, \'exec\'))" install --record /tmp/pip-qrvy2ohy-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.virtualenvs/py35/include/site/python3.5/pyrfr:\n running install\n running build\n running build_py\n creating build\n creating build/lib.linux-x86_64-3.5\n creating build/lib.linux-x86_64-3.5/pyrfr\n copying pyrfr/__init__.py -> build/lib.linux-x86_64-3.5/pyrfr\n running build_ext\n building \'pyrfr.regression\' extension\n creating build/temp.linux-x86_64-3.5\n creating build/temp.linux-x86_64-3.5/pyrfr\n x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I./include -I/root/.virtualenvs/py35/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/root/.virtualenvs/py35/include/python3.5m -c pyrfr/regression.cpp -o build/temp.linux-x86_64-3.5/pyrfr/regression.o -O2 -std=c++11\n cc1plus: warning: command line option \xe2\x80\x98-Wstrict-prototypes\xe2\x80\x99 is valid for Ada/C/ObjC but not for C++ [enabled by default]\n cc1plus: error: unrecognized command line option \xe2\x80\x98-std=c++11\xe2\x80\x99\n error: command \'x86_64-linux-gnu-gcc\' failed with exit status 1\n\n ----------------------------------------\nCommand "/root/.virtualenvs/py35/bin/python3.5 -u -c "import setuptools, tokenize;__file__=\'/tmp/pip-build-wt1wfz_q/pyrfr/setup.py\';f=getattr(tokenize, \'open\', open)(__file__);code=f.read().replace(\'\\r\\n\', \'\\n\');f.close();exec(compile(code, __file__, \'exec\'))" install --record /tmp/pip-qrvy2ohy-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.virtualenvs/py35/include/site/python3.5/pyrfr" failed with error code 1 in /tmp/pip-build-wt1wfz_q/pyrfr/\n
Run Code Online (Sandbox Code Playgroud)\n\n我认为关键问题是python3.5没有链接到gcc-4.8(甚至系统默认的python2.7也没有链接),但是google没有太大帮助。
\n最后我找到了解决方案..发现这x86_64-linux-gnu-gcc
是一个命令,尽管它看起来不像一个命令...
ubuntu 12 上的 python 似乎不会使用 /usr/bin/x86_64-linux-gnu-gcc
(link to /usr/bin/gcc-4.6
) 而不是/usr/bin/gcc
,我完全不明白他们为什么这样做......
解决办法很简单,只需
cd /usr/bin
rm x86_64-linux-gnu-gcc
ln -sf gcc-4.8 x86_64-linux-gnu-gcc
Run Code Online (Sandbox Code Playgroud)
如果你想改变 g++ 和 cpp,也可以这样做
rm x86_64-linux-gnu-cpp
ln -sf cpp-4.8 x86_64-linux-gnu-cpp
rm x86_64-linux-gnu-g++
ln -sf g++-4.8 x86_64-linux-gnu-g++
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9970 次 |
最近记录: |