- Saved searches
- Use saved searches to filter your results more quickly
- unable to execute ‘gcc’: No such file or directory error: command ‘gcc’ failed with exit status 1 #418
- unable to execute ‘gcc’: No such file or directory error: command ‘gcc’ failed with exit status 1 #418
- Comments
- Expected behavior
- Actual behavior
- Steps to reproduce the problem
- Code snippet (Note: Do not paste your credentials)
- python sdk version
- python version
- How to Fix Python `No such file or directory` Compiler Errors When Installing Packages
- Missing Compiler Errors
- Compiler Packages for Ubuntu and Debian
- Compiler Packages for Red Hat and Rocky Linux
- Windows Compiler Environments
- macOS Compiler Environments
- Conclusion
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to execute ‘gcc’: No such file or directory error: command ‘gcc’ failed with exit status 1 #418
unable to execute ‘gcc’: No such file or directory error: command ‘gcc’ failed with exit status 1 #418
Comments
Expected behavior
pip install —ignore-installed six watson-developer-cloud Dockerfile RUN should build the image successfully.
Actual behavior
pip install —ignore-installed six watson-developer-cloud has dependency on gcc. Therefore when you give it in Dockerfile than docker image build will get failed with below error:
unable to execute ‘gcc’: No such file or directory
error: command ‘gcc’ failed with exit status 1
Steps to reproduce the problem
step 1: create a Dockerfile with these below contents:
FROM python:2.7-slim WORKDIR /app ADD . /app RUN pip install --trusted-host pypi.python.org -r requirements.txt RUN pip install --ignore-installed six watson-developer-cloud EXPOSE 80 CMD ["python", "app.py"]
step 2: execute below cmd to create docker image:
docker image build -t arprasto/python-hello-world:v2 .
However if you add below 2 lines to Dockerfile than issue resolved:
RUN apt-get update RUN apt-get -y install gcc
Therefore this need to be added to Readme file.
Code snippet (Note: Do not paste your credentials)
from flask import Flask import os import socket import json from watson_developer_cloud import VisualRecognitionV3 # Connect to Redis app = Flask(__name__) cred = "api_key_json" @app.route("/") def hello(): img_url="http://www.dogbreedslist.info/uploads/allimg/dog-pictures/Rottweiler-1.jpg" visual_rec_svc = VisualRecognitionV3(version="2016-05-20",api_key=cred.get('api_key')) clazes = visual_rec_svc.classify(url=img_url,parameters=json.dumps(< 'classifier_ids': ['fruits_1462128776','SatelliteModel_6242312846','default'], 'threshold': 0.6 >)) html = "Hello !
" \ " '> this is the img
" \ "Hostname:
" \ "" return html.format(name=os.getenv("NAME", "there"), img_url=img_url, hostname=socket.gethostname(),filecontent=clazes) if __name__ == "__main__": app.run(host='127.0.0.1', port=80)
python sdk version
python version
The text was updated successfully, but these errors were encountered:
How to Fix Python `No such file or directory` Compiler Errors When Installing Packages
A common error that you may receive when installing Python modules is the No such file or directory error. This can be misleading, because you usually aren’t missing a file or directory from the package you’re trying to install. Instead, this error results from Python trying to call your system compiler during module installation. This is because the paths to your system compiler are often hardcoded into Python itself, and it is not finding the compiler files it needs. This tutorial will provide an example of this error, and the steps to fix it on multiple platforms.
Missing Compiler Errors
Python packages are typically installed using the pip package manager with the pip install command. pip will print a list of dependencies additionally required by the package you selected, and a long list of output from the install process. Sometimes, the installer will exit with an error, containing text like the following near the end of the output:
Output x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.10 -I/usr/local/lib/python3.10/dist-packages/numpy/core/include -I/usr/include/python3.10 -c radiomics/src/_cmatrices.c -o build/temp.linux-x86_64-3.10/radiomics/src/_cmatrices.o error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> pyradiomics note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
This particular error was the result of trying to install pd-dwi, a Python library used in chemotherapy research, using pip install pd-dwi .
Some Python libraries, especially those used for scientific computing, need to compile additional code locally on your machine after being installed. Python is a high-level, interpreted language that can run with only the Python interpreter itself present. Low-level languages like C or Rust, which Python libraries occasionally include for high-performance processing, need to be compiled and optimized before being executable. If there isn’t a compiler present on your system, the installation will fail.
On most modern platforms, when you install Python’s package manager, pip , it will also set up a compiler environment and the associated packages. However, there are a few reasons why this may not always happen. For example, it’s possible that the compiler could have been uninstalled by accident, or never installed in the first place. And unlike on Linux, Python packages usually aren’t installed by the system package manager on Mac or Windows, creating more opportunities for trouble.
The following steps of this tutorial will provide instructions for installing and verifying a Python-compatible compiler on Ubuntu/Debian Linux, on Red Hat/Rocky Linux, on Windows, and on macOS.
Compiler Packages for Ubuntu and Debian
On Ubuntu, you can install a package called build-essential that will provide all the packages needed for a modern, well-supported compiler environment. build-essential is what’s known as a meta-package. It doesn’t refer to any one package, but rather pulls in a number of common compiler tools as dependencies.
You can also install libpython3-dev . This is a longstanding Ubuntu/Debian ecosystem package that essentially “wires up” the compiler to Python, and provides all the needed backend configuration for calling your compiler automatically from Python or from pip . Usually, it is installed automatically along with pip , but if you install pip without using the package manager, you can miss it.
Install the packages with apt :
This will also install a number of dependencies. Afterward, you can verify that a compiler is available by checking for the existence of the make command on your system. To do that, use the which command:
make is the command that gcc , the most popular open-source compiler, uses to parse a Makefile , which is how compile instructions are provided within each package. If you now have a version of make installed on your path, try installing your Python module using pip again.
Compiler Packages for Red Hat and Rocky Linux
On Red Hat and Rocky Linux, you can use the groups functionality of the dnf package manager to install a group of packages that include a well-supported compiler environment. The group of packages you’ll install is called «Development Tools» .
Use two dnf commands to install the package group:
This will also install a number of dependencies. Next, you can install python3-devel , a longstanding Red Hat ecosystem package that essentially “wires up” the compiler to Python. python3-devel provides all the needed backend configuration for calling your compiler automatically from Python or from pip :
Afterward, you can verify that a compiler is available by checking for the existence of the make command on your system. To do that, use the which command:
make is the command that gcc , the most popular open-source compiler, uses to parse a Makefile , which is how compile instructions are provided within each package. If you now have a version of make installed on your path, try installing your Python module using pip again.
Windows Compiler Environments
Windows compiler issues can be trickier, because there are many different ways of installing Python, and each of them expect different compilers to be present:
- If you use Python with WSL2, it’s just like running Python under Linux, so you can follow the troubleshooting instructions for your distro (Ubuntu by default).
- If you use Python with Anaconda, it will provide its own compiler packages within the conda environment, usually avoiding any of these errors in the first place.
- If you use Python on Windows natively, there are a few other considerations. By default, Python on Windows tries to use the Microsoft Visual Studio Build Tools. This is a very large install and adds many Windows ecosystem packages that may be unfamiliar if you mostly work in the cloud, but should work automatically after installation, like installing make on Linux.
- If you already have a working version of open-source gcc and make build tooling installed in your Windows environment using MinGW or Chocolatey, you can tell Python to use this compiler on Windows instead, by creating a file at Lib/distutils/distutils.cfg relative to your Python install path and adding the following contents:
[build] compiler=mingw32 [build_ext] compiler=mingw32
If you have trouble installing a compiler on Windows, you can try to install a precompiled wheel package for the library you are installing instead, though this is less convenient than installing from pip and they are usually only available on an ad-hoc basis.
macOS Compiler Environments
macOS bundles its compiler toolchain into Apple’s development suite, XCode. Like Visual Studio on Windows, XCode is a complete development environment with its own interface, but you won’t actually need to use XCode itself to compile Python packages. Instead, you only need to make sure that the XCode packages themselves are installed. You can do this by running xcode-select –install :
You’ll be prompted to start the installation, and then prompted again to accept a software license. Then the tools will download and install automatically.
Conclusion
The Python ecosystem is very powerful, and welcoming to both novice and expert developers, but encountering gaps in its tooling can be confusing. In this tutorial, you learned how to fix errors that may arise as a result of missing compiler packages, and when Python needs to compile low-level code at module installation time.
Next, you may want to review our How to Code in Python series.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.