How to fix CMake ‘Could not find a package configuration file provided by “Coin” …’ on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at cMake/FreeCAD_Helpers/SetupCoin3D.cmake:13 (find_package):
  Could not find a package configuration file provided by "Coin" with any of
  the following names:

    CoinConfig.cmake
    coin-config.cmake

  Add the installation prefix of "Coin" to CMAKE_PREFIX_PATH or set
  "Coin_DIR" to a directory containing one of the above files.  If "Coin"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:86 (SetupCoin3D)

Solution:

sudo apt -y install libcoin-dev

Tested on Ubuntu 22.04

Posted by Uli Köhler in CMake, Linux

How to fix CMake ‘The imported target “Qt6::lprodump” references the file /usr/lib/qt6/libexec/lprodump …’ on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsTargets.cmake:131 (message):
  The imported target "Qt6::lprodump" references the file

     "/usr/lib/qt6/libexec/lprodump"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsTargets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsConfig.cmake:47 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:219 (find_package)
  cMake/FreeCAD_Helpers/SetupQt.cmake:33 (find_package)
  CMakeLists.txt:82 (include)

Solution:

sudo apt -y install qt6-tools-dev-tools

Tested on Ubuntu 22.04

Posted by Uli Köhler in CMake, Linux

How to fix CMake ‘The imported target “Qt6::lconvert” references the file /usr/lib/qt6/bin/lconvert …’ on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsTargets.cmake:131 (message):
  The imported target "Qt6::lconvert" references the file

     "/usr/lib/qt6/bin/lconvert"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsTargets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsConfig.cmake:47 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:219 (find_package)
  cMake/FreeCAD_Helpers/SetupQt.cmake:33 (find_package)
  CMakeLists.txt:82 (include)

 

Solution:

sudo apt -y install qt6-l10n-tools

Tested on Ubuntu 22.04

Posted by Uli Köhler in CMake, Linux

How to fix CMake ‘Failed to find Qt component “Core5Compat”‘ on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at cMake/FreeCAD_Helpers/SetupQt.cmake:33 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake

  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
  FOUND.  Reason given by package:

  Failed to find Qt component "Core5Compat".

  Expected Config file at
  "/usr/lib/x86_64-linux-gnu/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake"
  does NOT exist

  

Call Stack (most recent call first):
  CMakeLists.txt:82 (include)

 

 

Solution:

sudo apt -y install libqt6core5compat6-dev

Tested on Ubuntu 22.04

Posted by Uli Köhler in CMake, Linux

How to fix CMake ‘Failed to find Qt component “SvgWidgets”‘ on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at cMake/FreeCAD_Helpers/SetupQt.cmake:33 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake

  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
  FOUND.  Reason given by package:

  Failed to find Qt component "SvgWidgets".

  Expected Config file at
  "/usr/lib/x86_64-linux-gnu/cmake/Qt6SvgWidgets/Qt6SvgWidgetsConfig.cmake"
  does NOT exist

  

Call Stack (most recent call first):
  CMakeLists.txt:82 (include)

 

Solution:

sudo apt -y install libqt6svg6-dev

Tested on Ubuntu 22.04

Posted by Uli Köhler in CMake, Linux

How to fix CMake ‘Could not find a package configuration file provided by “VTK”‘ on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake:29 (find_package):
  Could not find a package configuration file provided by "VTK" with any of
  the following names:

    VTKConfig.cmake
    vtk-config.cmake

  Add the installation prefix of "VTK" to CMAKE_PREFIX_PATH or set "VTK_DIR"
  to a directory containing one of the above files.  If "VTK" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:71 (SetupSalomeSMESH)

Solution:

sudo apt -y install libvtk9-dev

Note that depending on the version of Ubuntu you use, you might need to use a slightly different version (9) of vtklibvtk9-dev works for Ubuntu 22.04

Posted by Uli Köhler in CMake, Linux

How to fix CMake ‘Failed to find XercesC…’ on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Failed to find XercesC (missing: XercesC_LIBRARY XercesC_INCLUDE_DIR
  XercesC_VERSION)
Call Stack (most recent call first):
  /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.25/Modules/FindXercesC.cmake:112 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cMake/FreeCAD_Helpers/SetupXercesC.cmake:4 (find_package)
  CMakeLists.txt:61 (SetupXercesC)

Solution:

sudo apt -y install libxerces-c-dev

 

Posted by Uli Köhler in CMake, Linux

How to fix CMake ‘Could not find a package configuration file provided by “yaml-cpp” …’ on Ubuntu

Problem:

When you try to build a CMake project, you see an error message such as

CMake Error at cMake/FreeCAD_Helpers/SetupLibYaml.cmake:3 (find_package):
  By not providing "Findyaml-cpp.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "yaml-cpp",
  but CMake did not find one.

  Could not find a package configuration file provided by "yaml-cpp" with any
  of the following names:

    yaml-cppConfig.cmake
    yaml-cpp-config.cmake

  Add the installation prefix of "yaml-cpp" to CMAKE_PREFIX_PATH or set
  "yaml-cpp_DIR" to a directory containing one of the above files.  If
  "yaml-cpp" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:56 (SetupYamlCpp)

Solution:

sudo apt -y install libyaml-cpp-dev

 

Posted by Uli Köhler in CMake, Linux

Python script to clean certain attributes in YAML files if they have specific values

This example script can be used to remove certain attributes from a YAML file’s entries in case they have certain default values.

#!/usr/bin/env python3
import yaml
import argparse
from pathlib import Path

def clean_yaml(data):
    if isinstance(data, dict):
        for key, value in list(data.items()):
            if key == 'offset3d' and (value == [0, 0, 0] or value == [0.0, 0.0, 0.0]):
                del data[key]
            elif key == 'rotate3d' and (value == [0, 0, 0] or value == [0.0, 0.0, 0.0]):
                del data[key]
            elif key == 'adhesivePos' and (value == [0, 0] or value == [0.0, 0.0]):
                del data[key]
            elif key == 'scale3d' and (value == [1, 1, 1] or value == [1.0, 1.0, 1.0]):
                del data[key]
            elif key == 'script3d' and value == '':
                del data[key]
            else:
                clean_yaml(value)
    elif isinstance(data, list):
        for item in data:
            clean_yaml(item)

def process_file(file_path):
    with open(file_path, 'r') as file:
        data = yaml.safe_load(file)

    clean_yaml(data)

    with open(file_path, 'w') as file:
        yaml.dump(data, file, default_flow_style=False)

def main():
    parser = argparse.ArgumentParser(description='Clean YAML files by removing offset3d and rotate3d if they are [0,0,0] or [0.0, 0.0, 0.0]')
    parser.add_argument('files', nargs='*', help='YAML files to process')

    args = parser.parse_args()

    if args.files:
        files = args.files
    else:
        files = list(Path('.').rglob('*.yaml'))

    for file_path in files:
        process_file(file_path)

if __name__ == "__main__":
    main()

 

Posted by Uli Köhler in Python, YAML

Python script to load & re-save YAMLs recursively

This can be used to fix PyYAML generating slightly different YAML files by formatting than any manually generated file. For example, you can use this script first to generate a clean diff for just re-saving, then run another script to modify the YAML for a cleaner diff.

#!/usr/bin/env python3
import argparse
import yaml
import pathlib

def load_and_save_yaml(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        data = yaml.safe_load(file)
    with open(file_path, 'w', encoding='utf-8') as file:
        yaml.safe_dump(data, file)

def process_files(file_paths):
    for file_path in file_paths:
        try:
            load_and_save_yaml(file_path)
            print(f"Processed: {file_path}")
        except Exception as e:
            print(f"Failed to process {file_path}: {e}")

def main():
    parser = argparse.ArgumentParser(description="Load and re-save YAML files.")
    parser.add_argument('files', nargs='*', help="YAML files to process. If not provided, searches for all *.yaml files in the current directory and subdirectories.")
    args = parser.parse_args()

    if args.files:
        file_paths = [pathlib.Path(file) for file in args.files]
    else:
        file_paths = list(pathlib.Path('.').rglob('*.yaml'))

    process_files(file_paths)

if __name__ == "__main__":
    main()

 

Posted by Uli Köhler in Python

How to add custom CSS to a Hugo site

In hugo.toml, add

[params]
custom_css = ["css/myblog.css"]

Now you need to find the the file in your theme where the layout head is generated. Use e.g.

ag '<link rel="stylesheet"'

to find which file this is

For me (tailbliss theme), it is themes/tailbliss/layouts/partial/head.html and I believe it’s quite similar for other themes as well.

In that file, add

{{ range .Site.Params.custom_css -}}
    <link rel="stylesheet" href="{{ . | absURL }}">
{{- end }}

Now, create the actual static CSS file in static/css/myblog.css.

When you now run hugo serve, you’ll see the changes introduced by your custom CSS file immediately.

 

 

Posted by Uli Köhler in Hugo

How to ignore “dirty” git submodules

Edit .gitmodules and add ignore = dirty to all modules where you want to ignore the -dirty state.

Example:

[submodule "themes/tailbliss"]
        path = themes/tailbliss
        url = https://github.com/ulikoehler/tailbliss.git
        ignore = dirty

 

Posted by Uli Köhler in git

How to export Python function call parameters as YAML

Use this decorator:

import functools
import inspect
import yaml
import sys

def print_params_as_yaml(key_arg, file_obj=sys.stdout):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            # Get the function signature
            sig = inspect.signature(func)
            # Bind the arguments to the function signature
            bound_arguments = sig.bind(*args, **kwargs)
            # Convert the bound arguments to a dictionary
            params = dict(bound_arguments.arguments)
            
            # Extract the value of the key_arg
            if key_arg not in params:
                raise ValueError(f"The key argument '{key_arg}' is not provided in the function call.")
            
            key_value = params.pop(key_arg)
            # Add the function name to the parameters
            params['func'] = func.__name__
            yaml_dict = {key_value: params}
            
            # Convert the parameters dictionary to YAML format
            params_yaml = yaml.dump(yaml_dict, default_flow_style=False)
            
            # Print or write the parameters in YAML format
            file_obj.write(params_yaml)
            file_obj.write('\n\n')
            
            # Execute the function
            return func(*args, **kwargs)
        
        return wrapper
    return decorator

key_arg is the function parameter to use

Example usage:

# Example usage:
@print_params_as_yaml(key_arg='a')
def example_function(a, b, c=3, d=4):
    return b + c + d

# Test the decorator
example_function("foo", 2, d=5)

# Prints
# foo:
#   b: 2
#   d: 5
#   func: example_function

 

Posted by Uli Köhler in Python

How to extrude a face in CadQuery

Use

face_to_extrude.wires().toPending().extrude(...)

Full example

import cadquery as cq

box = cq.Workplane("XY").box(1, 1, 1)

face_to_extrude = box.faces(">Z")

result = face_to_extrude.wires().toPending().extrude(2, taper=45)

 

Posted by Uli Köhler in CadQuery, Python

How to fix ‘ValueError: No pending wires present’ when extruding a face in CadQuery

Problem:

You are trying to extrude an existing face using CadQuery (cq) using code similar to

import cadquery as cq

box = cq.Workplane("XY").box(1, 1, 1)

face_to_extrude = box.faces(">Z")

result = face_to_extrude.extrude(2, taper=45)

But when you try to run this, you see the following error message:

{
    "name": "ValueError",
    "message": "No pending wires present",
    "stack": "---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 7
      3 box = cq.Workplane(\"XY\").box(1, 1, 1)
      5 face_to_extrude = box.faces(\">Z\")
----> 7 result = face_to_extrude.extrude(2, taper=45)

File /usr/local/lib/python3.10/dist-packages/cadquery/cq.py:3078, in Workplane.extrude(self, until, combine, clean, both, taper)
   3075     r = self._extrude(None, both=both, taper=taper, upToFace=until)
   3077 elif isinstance(until, (int, float)):
-> 3078     r = self._extrude(until, both=both, taper=taper, upToFace=None)
   3080 elif isinstance(until, (str, Face)) and combine is False:
   3081     raise ValueError(
   3082         \"`combine` can't be set to False when extruding until a face\"
   3083     )

File /usr/local/lib/python3.10/dist-packages/cadquery/cq.py:3676, in Workplane._extrude(self, distance, both, taper, upToFace, additive)
   3673     return facesList
   3675 # process sketches or pending wires
-> 3676 faces = self._getFaces()
   3678 # check for nested geometry and tapered extrusion
   3679 for face in faces:

File /usr/local/lib/python3.10/dist-packages/cadquery/cq.py:3624, in Workplane._getFaces(self)
   3621         rv.extend(el)
   3623 if not rv:
-> 3624     rv.extend(wiresToFaces(self.ctx.popPendingWires()))
   3626 return rv

File /usr/local/lib/python3.10/dist-packages/cadquery/cq.py:129, in CQContext.popPendingWires(self, errorOnEmpty)
    123 \"\"\"
    124 Get and clear pending wires.
    125 
    126 :raises ValueError: if errorOnEmpty is True and no wires are present.
    127 \"\"\"
    128 if errorOnEmpty and not self.pendingWires:
--> 129     raise ValueError(\"No pending wires present\")
    130 out = self.pendingWires
    131 self.pendingWires = []

ValueError: No pending wires present"

Solution:

Use

face_to_extrude.wires().toPending().extrude(...)

which will create pending wires from the selected face.

Full example:

import cadquery as cq

box = cq.Workplane("XY").box(1, 1, 1)

face_to_extrude = box.faces(">Z")

result = face_to_extrude.wires().toPending().extrude(2, taper=45)

Posted by Uli Köhler in Allgemein

How to get historical soil temperature data in Python using pandas and OpenMeteo

import openmeteo_requests

import requests_cache
import pandas as pd
from retry_requests import retry

# Setup the Open-Meteo API client with cache and retry on error
cache_session = requests_cache.CachedSession('.cache', expire_after = 3600)
retry_session = retry(cache_session, retries = 5, backoff_factor = 0.2)
openmeteo = openmeteo_requests.Client(session = retry_session)

# Make sure all required weather variables are listed here
# The order of variables in hourly or daily is important to assign them correctly below
url = "https://archive-api.open-meteo.com/v1/era5"
params = {
        'latitude': 48.1351,   # Latitude of Munich
        'longitude': 11.5820,  # Longitude of Munich
    'start_date': '2023-04-01',
    'end_date': '2024-05-16',
    "hourly": "soil_temperature_7_to_28cm"
}
responses = openmeteo.weather_api(url, params=params)

# Process first location. Add a for-loop for multiple locations or weather models
response = responses[0]
print(f"Coordinates {response.Latitude()}°N {response.Longitude()}°E")
print(f"Elevation {response.Elevation()} m asl")
print(f"Timezone {response.Timezone()} {response.TimezoneAbbreviation()}")
print(f"Timezone difference to GMT+0 {response.UtcOffsetSeconds()} s")

# Process hourly data. The order of variables needs to be the same as requested.
hourly = response.Hourly()
hourly_soil_temperature = hourly.Variables(0).ValuesAsNumpy()

hourly_data = {"date": pd.date_range(
    start = pd.to_datetime(hourly.Time(), unit = "s", utc = True),
    end = pd.to_datetime(hourly.TimeEnd(), unit = "s", utc = True),
    freq = pd.Timedelta(seconds = hourly.Interval()),
    inclusive = "left"
)}
hourly_data["soil_temperature"] = hourly_soil_temperature

hourly_dataframe = pd.DataFrame(data = hourly_data)
print(hourly_dataframe)
hourly_dataframe.set_index("date", inplace = True)

hourly_dataframe.plot()

 

Posted by Uli Köhler in pandas, Python

How to get function name as string in Python

The following variant also works reliably for member functions:

def func_name(func):
    """
    Get the name of a function.
    """
    if hasattr(func, '__qualname__'):
        return func.__qualname__
    elif hasattr(func, '__name__'):
        return func.__name__
    else:
        return repr(func)

 

Posted by Uli Köhler in Python

How to set custom esptool “–before” reset method in PlatformIO

Use these options:

board_upload.before_reset = usb_reset
board_upload.after_reset = no_reset

 

Posted by Uli Köhler in ESP8266/ESP32, PlatformIO

How to fix PlatformIO “UnknownPackageError: Could not find the package ….” for recently updated package

Problem:

When you want to install a PlatformIO library which has been updated recently, you see an error message such as

UnknownPackageError: Could not find the package with 'ulikoehler/QuickSPI @ ^1.1.1' requirements for your system 'linux_x86_64

Solution:

Delete the ~/.platformio/.cache, then try again.

On Windows, this is directory located here: C:\Users\<user>\.platformio\.cache

Posted by Uli Köhler in PlatformIO

How to force upgrade all KiCad symbol libraries

for i in *.kicad_sym ; do echo -n "$i: " ; kicad-cli sym upgrade --force $i; done

 

Posted by Uli Köhler in KiCAD
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPTPrivacy &amp; Cookies Policy