No such file or directory c++ Error [CentOS]

Updated on December 7, 2022

While installing pip packages through the requirements file on the minimal CentOS Stream 8 server with python v3.7, encountered the error “No such file or directory c++” during the installation of grpcio package. Below is the complete error message:

# pip3 install -r requirements.txt
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting cotyledon>=1.5.0 (from -r requirements.txt (line 5))
Downloading (42kB)
100% |████████████████████████████████| 51kB 1.2MB/s
Collecting Flask>=0.12.3 (from -r requirements.txt (line 6))
Downloading (95kB)
100% |████████████████████████████████| 102kB 2.8MB/s
Collecting futurist>=1.6.0 (from -r requirements.txt (line 7))
Collecting grpcio>=1.25.0 (from -r requirements.txt (line 8))
Downloading (22.0MB)
100% |████████████████████████████████| 22.0MB 24kB/s
Complete output from command python egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-ztl0h28k/grpcio/", line 263, in <module>
if check_linker_need_libatomic():
File "/tmp/pip-build-ztl0h28k/grpcio/", line 213, in check_linker_need_libatomic
File "/usr/lib64/python3.6/", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.6/", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'c++': 'c++'

Command "python egg_info" failed with error code 1 in /tmp/pip-build-ztl0h28k/grpcio/

Solution: This is because of the unavailability of build environments on the server. By default the minimal CentOS Stream 8 server doesn’t come with the build environments such as gcc-c++ and python3-devel.

On CentOS:

Install the build environments as below:

# yum install -y gcc-c++ python3-devel

On Debian:

# apt install build-essential

On Ubuntu:

# apt install build-essential python-dev g++

And also first upgrade pip3 and thenupgrade setuptools as below:

# pip3 install --upgrade pip

# python3 -m pip install --upgrade setuptools

Now the installation of packages doesn’t fail.

Was this article helpful?

Related Articles

Leave a Comment