[Solved] Issue with the 3D generator script

I am trying to create some 3D models using the generator script from gitlab but I run into an issue with numpy that I cannot solve. For some reason it cannot be imported properly

packages3D-generator$ pip install numpy
Requirement already satisfied: numpy in /home/user/anaconda3/lib/python3.9/site-packages (1.21.5)
(base) user@pc:/home/user/Documents/KiCad_Libraries/kicad-packages3D-generator$ ./generator.py --output_dir /tmp/3dmodels --library Capacitor_THT --package CP_Axial_L10.0mm_D4.5mm_P15.00mm_Horizontal --enable-vrml False
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
Traceback (most recent call last):
  File "/home/user/Documents/KiCad_Libraries/kicad-packages3D-generator/./generator.py", line 52, in <module>
    main()
  File "/home/user/Documents/KiCad_Libraries/kicad-packages3D-generator/./generator.py", line 36, in main
    mod = importlib.import_module(args.library + ".main_generator")
  File "/home/user/anaconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/user/Documents/KiCad_Libraries/kicad-packages3D-generator/Capacitor_THT/main_generator.py", line 62, in <module>
    import cadquery as cq
  File "/home/user/anaconda3/lib/python3.9/site-packages/cadquery/__init__.py", line 22, in <module>
    from .occ_impl import exporters
  File "/home/user/anaconda3/lib/python3.9/site-packages/cadquery/occ_impl/exporters/__init__.py", line 10, in <module>
    from ...cq import Workplane
  File "/home/user/anaconda3/lib/python3.9/site-packages/cadquery/cq.py", line 61, in <module>
    from .sketch import Sketch
  File "/home/user/anaconda3/lib/python3.9/site-packages/cadquery/sketch.py", line 28, in <module>
    from .occ_impl.sketch_solver import (
  File "/home/user/anaconda3/lib/python3.9/site-packages/cadquery/occ_impl/sketch_solver.py", line 10, in <module>
    import nlopt
  File "/home/user/anaconda3/lib/python3.9/site-packages/nlopt/__init__.py", line 1, in <module>
    from .nlopt import *
  File "/home/user/anaconda3/lib/python3.9/site-packages/nlopt/nlopt.py", line 20, in <module>
    from . import _nlopt
ImportError: numpy.core.multiarray failed to import

I’m not sure, but the error below suggests you have an older version of numpy installed. Maybe updating numpy helps.

thank. For some reason conda wasn’t installing the latest version and I had to run pip install numpy --upgrade

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.