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 https://files.pythonhosted.org/packages/b1/13/ca15614b839e075669852e0337e19c7ddfb031fcd7ac84d51260dfd4695e/cotyledon-1.7.3-py2.py3-none-any.whl (42kB) 100% |████████████████████████████████| 51kB 1.2MB/s Collecting Flask>=0.12.3 (from -r requirements.txt (line 6)) Downloading https://files.pythonhosted.org/packages/cd/77/59df23681f4fd19b7cbbb5e92484d46ad587554f5d490f33ef907e456132/Flask-2.0.3-py3-none-any.whl (95kB) 100% |████████████████████████████████| 102kB 2.8MB/s Collecting futurist>=1.6.0 (from -r requirements.txt (line 7)) Downloading https://files.pythonhosted.org/packages/b3/55/d9c92dd20be0527a6e47285bb6d4a001659726872e8ee69826ee47454bb8/futurist-2.4.1-py3-none-any.whl Collecting grpcio>=1.25.0 (from -r requirements.txt (line 8)) Downloading https://files.pythonhosted.org/packages/81/9a/6b33e8d15850356772f0ee6489bc8346a7aa90f0c86733283e139740865e/grpcio-1.48.2.tar.gz (22.0MB) 100% |████████████████████████████████| 22.0MB 24kB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-ztl0h28k/grpcio/setup.py", line 263, in <module> if check_linker_need_libatomic(): File "/tmp/pip-build-ztl0h28k/grpcio/setup.py", line 213, in check_linker_need_libatomic stderr=PIPE) File "/usr/lib64/python3.6/subprocess.py", line 729, in __init__ restore_signals, start_new_session) File "/usr/lib64/python3.6/subprocess.py", 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 setup.py 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.