2016-12-16 258 views
0

我想安裝一個依賴於pyrfr的auto-sklearn軟件包。安裝命令爲curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install如何將python gcc綁定到gcc 4.8版本?

我的Env:ubuntu 12.04,python3.5-dev(在virtualenv中),安裝了gcc 4.8和g ++ 4.8。

我安裝由gcc和g ++:

sudo apt-get install python-software-properties 
sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update 

sudo apt-get install gcc-4.8 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 

Defaut GCC設置正確:

➜ ~ gcc -v 
Using built-in specs. 
COLLECT_GCC=gcc 
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper 
Target: x86_64-linux-gnu 
Configured 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 
Thread model: posix 
gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04) 

但是我發現蟒殼仍然顯示[4.6.3 GCC]:

➜ ~ python 
Python 3.5.2 (default, Jul 17 2016, 17:38:18) 
[GCC 4.6.3] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> 

並且安裝pyrfr還在說(因爲需要gcc 4.7或以上版本):

cc1plus: error: unrecognized command line option ‘-std=c++11’ 
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 

更多細節錯誤日誌:

Collecting pyrfr 
    Downloading http://mirrors.aliyun.com/pypi/packages/95/90/95f77f76c2e3d44577ff2b96b0d365429797d9f83632b84d2c91d2b7a73a/pyrfr-0.2.0.tar.gz (340kB) 
    100% |████████████████████████████████| 348kB 4.9MB/s 
Building wheels for collected packages: pyrfr 
    Running setup.py bdist_wheel for pyrfr ... error 
    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: 
    running bdist_wheel 
    running build 
    running build_py 
    creating build 
    creating build/lib.linux-x86_64-3.5 
    creating build/lib.linux-x86_64-3.5/pyrfr 
    copying pyrfr/__init__.py -> build/lib.linux-x86_64-3.5/pyrfr 
    running build_ext 
    building 'pyrfr.regression' extension 
    creating build/temp.linux-x86_64-3.5 
    creating build/temp.linux-x86_64-3.5/pyrfr 
    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 
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default] 
    cc1plus: error: unrecognized command line option ‘-std=c++11’ 
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 

    ---------------------------------------- 
    Failed building wheel for pyrfr 
    Running setup.py clean for pyrfr 
Failed to build pyrfr 
Installing collected packages: pyrfr 
    Running setup.py install for pyrfr ... error 
    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: 
    running install 
    running build 
    running build_py 
    creating build 
    creating build/lib.linux-x86_64-3.5 
    creating build/lib.linux-x86_64-3.5/pyrfr 
    copying pyrfr/__init__.py -> build/lib.linux-x86_64-3.5/pyrfr 
    running build_ext 
    building 'pyrfr.regression' extension 
    creating build/temp.linux-x86_64-3.5 
    creating build/temp.linux-x86_64-3.5/pyrfr 
    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 
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default] 
    cc1plus: error: unrecognized command line option ‘-std=c++11’ 
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 

    ---------------------------------------- 
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" failed with error code 1 in /tmp/pip-build-wt1wfz_q/pyrfr/ 

我認爲,問題的關鍵是python3.5不鏈接到GCC-4.8(甚至是系統默認的python2.7不算),但谷歌沒有太大的幫助。

+0

你可以嘗試通過刪除gcc的所有替代品,如sudo update-alternatives --remove-all gcc – lsunny

回答

0

Finnally我找到解決辦法..發現x86_64-linux-gnu-gcc是一個命令,儘管它沒有看起來像一個命令

似乎在Ubuntu 12蟒蛇不會使用/usr/bin/x86_64-linux-gnu-gcc(鏈接到/usr/bin/gcc-4.6)代替的/usr/bin/gcc,我完全coundn't明白爲什麼他們要這樣做?

的sulotion很簡單,只需

cd /usr/bin 
rm x86_64-linux-gnu-gcc 
ln -sf gcc-4.8 x86_64-linux-gnu-gcc 

如果你想改變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++