no module named 'airfoil_db'

65 views
Skip to first unread message

Peter Kämpf

unread,
Jul 21, 2024, 2:37:36 AM7/21/24
to MachUp Forum
Hi,
I just installed both MachUpX and AirfoilDatabase on my system (MacOC 14.5, Python 3.9.13) side-by-side in the same directory. When running the post-installation tests, 61 of them passed but two failed, the first with the error message 
ModuleNotFoundError: No module named 'airfoil_db'

That is strange. I have XFoil installed and in my Path, and AirfoilDatabase/airfoil_db definitely exists. What is also strange is that the NACA0012 airfoil polar within AirfoilDatabase/dev/xfoil_test/test.txt has been computed with a Reynolds number set to zero. Why would I need an inviscid calculation?

The full error message reads:

        # Check the proper files have been created

>       assert os.path.exists(altered_input_name.replace(".json", "_solve_forces.json"))

E       AssertionError: assert False

E        +  where False = <function exists at 0x1029c6940>('unique_name_solve_forces.json')

E        +    where <function exists at 0x1029c6940> = <module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py'>.exists

E        +      where <module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py'> = os.path

E        +    and   'unique_name_solve_forces.json' = <built-in method replace of str object at 0x10987ef80>('.json', '_solve_forces.json')

E        +      where <built-in method replace of str object at 0x10987ef80> = 'unique_name.json'.replace


test/main_tests/test_main.py:36: AssertionError

---------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------

Traceback (most recent call last):

  File "<frozen runpy>", line 189, in _run_module_as_main

  File "<frozen runpy>", line 148, in _get_module_details

  File "<frozen runpy>", line 112, in _get_module_details

  File "/Users/peter/Applications/Python/PyVFE/aero/MachUpX/machupX/__init__.py", line 9, in <module>

    from machupX.scene import Scene

  File "/Users/peter/Applications/Python/PyVFE/aero/MachUpX/machupX/scene.py", line 14, in <module>

    from airfoil_db import DatabaseBoundsError

ModuleNotFoundError: No module named 'airfoil_db'

I did check and the proper files exist. But it seems they cannot be found. Where should AirfoilDatabase be located relative to MachUpX? And could someone please help me with this error? 
Regards,
Peter

Cory Goates

unread,
Jul 22, 2024, 11:52:28 AM7/22/24
to MachUp Forum
Did you use "pip install ." to install AirfoilDatabase? Or did you just put the files on your computer? Running the pip install is necessary for MachUpX to be able to find airfoil_db.

Peter Kämpf

unread,
Jul 27, 2024, 10:49:41 AM7/27/24
to MachUp Forum
Yes, I did.

Now I have narrowed the error down to DatabaseBoundsError which cannot be found:

peter@MBP2023 MachUpX % python                             

Python 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import airfoil_db

>>> pass

>>> quit()

peter@MBP2023 MachUpX % python test/main_tests/test_main.py

Traceback (most recent call last):

  File "<frozen runpy>", line 189, in _run_module_as_main

  File "<frozen runpy>", line 148, in _get_module_details

  File "<frozen runpy>", line 112, in _get_module_details

  File "/Users/peter/Applications/Python/PyVFE/aero/MachUpX/machupX/__init__.py", line 9, in <module>

    from machupX.scene import Scene

  File "/Users/peter/Applications/Python/PyVFE/aero/MachUpX/machupX/scene.py", line 14, in <module>

    from airfoil_db import DatabaseBoundsError

ImportError: cannot import name 'DatabaseBoundsError' from 'airfoil_db' (unknown location)

Traceback (most recent call last):

  File "/Users/peter/Applications/Python/PyVFE/aero/MachUpX/test/main_tests/test_main.py", line 54, in <module>

    test_main()

  File "/Users/peter/Applications/Python/PyVFE/aero/MachUpX/test/main_tests/test_main.py", line 36, in test_main

    assert os.path.exists(altered_input_name.replace(".json", "_solve_forces.json"))

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AssertionError

peter@MBP2023 MachUpX % 


When I launch Python and import airfoil_db, it can be found. I threw in a „pass“ to make this part stand out a bit more. When I then proceed to run the tests (by „py.test“ or as shown here, makes no difference, but produces a more detailed error message), the database part DatabaseBoundsError cannot be found. So it is not the whole database, but some part which cannot be located. The printout when running py.test is longer and the error message less specific.

And even with almost 6 million files searched on my system, anything named „DatabaseBoundsError“ is nowhere to be found.

Suspecting an excessively tight access control by MacOS, I even moved my Xfoil executable to the same directory and added this to the PATH, but got the same result. I'm still stuck.

Regards,
Peter

Cory Goates

unread,
Jul 30, 2024, 12:07:55 PM7/30/24
to MachUp Forum
Very strange... I am not at all familiar with macOS, but let's see what we can do.

DatabaseBoundsError is defined in airfoil_db/exceptions.py. This specific exception is imported into airfoil_db in the initialization (__init__.py) when airfoil_db gets imported. At least, that should be what happens...

Peter Kämpf

unread,
Aug 1, 2024, 1:35:31 AM8/1/24
to MachUp Forum
I have now re-arranged all the parts and got them to work again. Since building airfoil_db did not have the desired result, I placed the airfoil scripts with the MachUpX scripts and include the database parts not as pre-compiled modules but as parts of the script. For example, I have replaced "from airfoil_db import DatabaseBoundsError" by "from AirfoilDatabase.airfoil_db.exceptions import DatabaseBoundsError". This gets rid of the error messages.

Peter Kämpf

unread,
Aug 1, 2024, 1:52:36 AM8/1/24
to MachUp Forum
The result from examples/Traditional looks credible:
{
    "traditional_airplane": {
        "alpha": 10.652497601509497,
        "elevator": -8.65591782707081
    }
}
However, the flying wing is clearly outside of its linear range:
{
    "flying_wing": {
        "alpha": 9.4575781417973,
        "elevator": -70.22934657686557
    }
}
Are those the expected results?

Cory Goates

unread,
Aug 6, 2024, 1:38:02 PM8/6/24
to MachUp Forum
Very interesting. I will need to have a second look at how that module is initialized. I'm glad you got it working though!

Yes, those numbers look about right to me. The flying wing is somewhat of a contrived case. I would not expect those results to be realistic.

Peter Kämpf

unread,
Aug 7, 2024, 11:16:11 AM8/7/24
to MachUp Forum
Hi Cory,
I have now looked more deeply into Python modules, and your software looks fine, according to all the documentation I have read. However, now I have tried all manners of installing Python on a Mac (Macports, Homebrew and rye) and non of them seem to like the airfoil database module. I am still struggling to understand what is going on, and one side effect is that my elaborate structure of Python installations is all screwed up. Python is the modern equivalent of  Windows dependency hell, where every piece of software required its own bunch of mutually conflicting dlls to run/crash. Don't get me wrong, I think the Python mess I had before was awful (but I was not aware of it), and now I am rebuilding it with more rigour.
Regards, 
Peter

Cory Goates

unread,
Aug 7, 2024, 7:43:48 PM8/7/24
to MachUp Forum
Haha yeah Python dependencies get pretty bad. Good luck! Sorry I can't be of more help, but I can't remember the last time I even touched a Mac...

Peter Kämpf

unread,
Aug 8, 2024, 3:58:35 AM8/8/24
to MachUp Forum
If you want, you can add my results to the documentation. I selected the most popular way of installing Python (Homebrew) and had to manually place the airfoil_db and machupX modules (from AirfoilDatabase/build/lib/airfoil_db and MachUpX/build/lib, respectively) in /opt/homebrew/lib/python3.12/site-packages. However, one out of 63 tests still fails due to a too large residual, but I guess a few more iteration steps could cure that.

The error message is 
>       assert abs(FM["test_plane"]["total"]["FL"]+1.921431422738798)<1e-10
E       assert 0.0045834797994268595 < 1e-10
E        +  where 0.0045834797994268595 = abs((-1.926014902538225 + 1.921431422738798))
while executing test_swept_wing_with_aerodynamic_twist.

Peter Kämpf

unread,
Aug 8, 2024, 9:52:44 AM8/8/24
to MachUp Forum
For a MacPort installation the modules go into /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages. Of course, the 3.12 part is for Python 3.12 and needs be replaced with the installed version number of Python.
Reply all
Reply to author
Forward
0 new messages