What to do if python says "fatal error:'stdio.h' file not found"

Target person

As the title suggests, for those who are suffering from this error. I had a lot of trouble when I was told when I used f2py (now integrated with numpy) to call fortran as a python module. The environment is Mac OS 10.15 Catalina. If you have a version lower than that, there is a lot of information available, so I will omit it (you can download the command line tool from the official page and unpack it).

Conclusion

Since it is just a memorandum, I conclude from the beginning. Execute the following command in the terminal.

$ sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/

You can now put a symbolic link to the Xcode header in / usr / local / include /. After that, for example

$ python3 -m numpy.f2py -c hello.f90 -m hello

If you do, you will have a file named hello.cpython-38-darwin.so etc.

$ python3 f2.py
 Hello from Fortran!
 a=           4

If so, it will work.

Code used

f2.py


import hello


hello.foo(4)

hello.f90


  subroutine foo(a)
    integer :: a
    write(*,*) "Hello from Fortran!" !Output characters here
    write(*,*) "a=",a !Output an integer here
  end subroutine foo

Recommended Posts

What to do if python says "fatal error:'stdio.h' file not found"
What to do if No Python documentation found for ... appears in pydoc
What to do if you get "Python not configured." Using PyDev in Eclipse
What to do if sys / cdefs.h does not exist
What to do if pyenv is not enabled (zsh)
What to do if you get `No kernel for language python found` in Hydrogen
What to do if the progress bar is not displayed in tqdm of python
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do if Python does not switch from the System version in pyenv
What to do with PYTHON release?
What to do if you can't install pyaudio with pip #Python
What to do if you get a minus zero in Python
What to do if Insecure Platform Warning appears when running Python
What to do if PyAudio cannot be installed on Python 3.7, 3.8, 3.9 on Windows
What to do if there is a decimal in python json .dumps
What to do if you couldn't send an email to Yahoo with Python.
What to do if you can't use scikit grid search in Python
What to do if ipython and python start up with different versions
What to do if you get lost in file reference with FileNotFoundError
What to do if pyenv install does not proceed with an error
What to do if the server doesn't start with python manage.py runserver
What to do if you get Could not fetch URL 443 with pip
What to do if pipreqs results in UnicodeDecodeError
What to do if you can't pipenv shell
[Python] What I did to do Unit Test
Note: What to do if pip install fails
What to do if rails s doesn't work
What to do if pip cannot be installed
What to do if atom autocomplete-python doesn't work
What to do to get google spreadsheet in python
What to do if Docker-sync suddenly stops working
What to do if "amazon-linux-extras" → "No module named amazon_linux_extras"
[Python] What to do if an error occurs in pip (pyinstaller, pyautogui, etc.)
What to do if you get a "No versions found" error in pipenv
What to do if you get angry with swapon failed: Operation not permitted
What to do if a Unicode Encode Error occurs in Sublime Text Python
What to do if you get an error when installing python with pyenv
What to do when [Errno 2] No such file or directory appears in Python
What to do if NotADirectoryError: [Errno 20] Not a directory:'xdg-settings' appears in jupyter notebook
What to do if Japanese language support is not completely installed on Ubuntu 16.04
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do if pip install fails in Xcode 5.1
What to do if you can't pip install mysqlclient
What to do if "export" keeps appearing on terminal when trying to put Python on macOS
What to do when python3 type venv does not work well on Raspberry Pi
What to do if you get an OpenSSL error when installing Python 2 with pyenv
No module named What to do if you get'libs.resources'
What to do if the Microsoft Store opens even if you run python on Windows
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
What to do if SciPy installation fails on CentOS
What to do when gdal_merge creates a huge file
What to do if ENOENT: no such file or directory appears during npm install
What to do if the print command itself causes an error in Maya python
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if a UnicodeDecodeError occurs in pip
What to do when Python starts up in Anaconda does not come out unexpectedly
What to do if Sort imports get stuck in VS Code's Python Extension (around 2020/09)
How to install and use pyenv, what to do if you can't switch python versions
What to do when "cannot import name xxx" [Python]
What to do if pip install fails to install dependent libraries
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3