55

I'm trying to install this python module, which requires compilation (on Ubuntu 16.04). I'm struggling to understand exactly what's causing it stall; what am I missing?

(xenial)chris@localhost:~$ pip install swigibpy
Collecting swigibpy
  Using cached swigibpy-0.4.1.tar.gz
Building wheels for collected packages: swigibpy
  Running setup.py bdist_wheel for swigibpy ... error
  Complete output from command /home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmptqb6ctskpip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  copying swigibpy.py -> build/lib.linux-x86_64-3.5
  running build_ext
  building '_swigibpy' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/IB
  creating build/temp.linux-x86_64-3.5/IB/PosixSocketClient
  gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -I/home/chris/anaconda3/include/python3.5m -c IB/PosixSocketClient/EClientSocketBase.cpp -o build/temp.linux-x86_64-3.5/IB/PosixSocketClient/EClientSocketBase.o -Wno-switch
  gcc: error trying to exec 'cc1plus': execvp: No such file or directory
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for swigibpy
  Running setup.py clean for swigibpy
Failed to build swigibpy
Installing collected packages: swigibpy
  Running setup.py install for swigibpy ... error
    Complete output from command /home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yv9u0wok-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    copying swigibpy.py -> build/lib.linux-x86_64-3.5
    running build_ext
    building '_swigibpy' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/IB
    creating build/temp.linux-x86_64-3.5/IB/PosixSocketClient
    gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -I/home/chris/anaconda3/include/python3.5m -c IB/PosixSocketClient/EClientSocketBase.cpp -o build/temp.linux-x86_64-3.5/IB/PosixSocketClient/EClientSocketBase.o -Wno-switch
    gcc: error trying to exec 'cc1plus': execvp: No such file or directory
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yv9u0wok-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-162vhh_i/swigibpy/
Michael M.
  • 10,486
  • 9
  • 18
  • 34
cjm2671
  • 18,348
  • 31
  • 102
  • 161

8 Answers8

76

The following worked for me:

sudo apt-get install g++
Glen Thompson
  • 9,071
  • 4
  • 54
  • 50
43

The routine commands that saved me time after time for such errors:

sudo apt update
sudo apt upgrade
sudo apt install gcc python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev g++

Hope it works.

jkoop
  • 113
  • 1
  • 7
DarkDiamonD
  • 662
  • 6
  • 10
22

This link helped me to fix this issue.

You need to run below command to get g++ installed

yum install gcc-c++

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Sourabh Jain
  • 628
  • 6
  • 20
  • 1
    The question is about an Ubuntu system (hence apt-get for installation), not fedora. – emher Apr 11 '19 at 12:03
  • 2
    @emher Could still be helpful to others that come here since the title or tags do not mention Ubuntu. – MattSt Jan 14 '22 at 10:21
  • This worked for me. Thanks. OS: `Fedora Server 29` Command: `dnf install -y gcc-c++` – Jonny Mar 16 '22 at 13:09
  • @Sourabh Jain: It did, actually, it seems to have moved me one step ahead in my quest for setting up fastText on Amazon Linux (https://stackoverflow.com/q/73712537/1091386) I'll answer there and quote you - if you want some points, please feel free to answer there and I'll accept yours :) – icedwater Sep 15 '22 at 06:22
8

For Conda environments the following should help:

conda install gcc_linux-64
conda install gxx_linux-64

See an old discussion about this issue here.

dsalaj
  • 2,857
  • 4
  • 34
  • 43
  • 1
    I had gcc-c++ already installed but the error was still there. This fixed it. Thank you! – simo23 Oct 03 '21 at 14:18
  • 1
    I'd add that it may be useful to run `ln ~/.conda/envs//bin/x86_64-conda-linux-gnu-gcc /home/grybouilli/.conda/envs//bin/gcc` and `ln ~/.conda/envs//bin/x86_64-conda-linux-gnu-g++ /home/grybouilli/.conda/envs//bin/g++` to ensure that `gcc file.c` and other similar command will use your conda gcc version. Make sure to replace with whatever conda environment name you're using – grybouilli Jun 13 '23 at 09:07
  • 1
    Thank you so much this finally solved my problem – Yousef Jul 07 '23 at 00:04
7

That helped me to build Python greenlet on Docker alpine

apk add g++
Mike Reiche
  • 382
  • 3
  • 12
1

On SUSE I used

sudo zypper install gcc-c++
Space
  • 11
  • 1
0

You need build tools. In Ubuntu, use:

sudo apt install build-essential
Duke
  • 7,070
  • 3
  • 38
  • 28
0

On RHEL / Almalinux / CentOS and clones:

dnf install gcc-c++
Orsiris de Jong
  • 2,819
  • 1
  • 26
  • 48