pythonfontconfig

pip install fontconfig getting SyntaxError : Missing parentheses in call to 'exec'


I am trying to install the fontconfig but it gives the following error. Is there any other way for installing this pack?

Collecting fontconfig
  Downloading fontconfig-0.1.zip (121 kB)
     ---------------------------------------- 122.0/122.0 kB 70.8 kB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      Traceback (most recent call last):
        File "...\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "...\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "...\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "...\AppData\Local\Temp\pip-build-env-gh6zzwr6\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "...\AppData\Local\Temp\pip-build-env-gh6zzwr6\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "...\AppData\Local\Temp\pip-build-env-gh6zzwr6\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "...\AppData\Local\Temp\pip-build-env-gh6zzwr6\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 9
          exec line in glb
          ^^^^^^^^^^^^^^^^
      SyntaxError: Missing parentheses in call to 'exec'. Did you mean exec(...)?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Solution

  • fontconfig didn't update for a while. You can use fontconfig-py or use GObjectIntrospection based TypeLib.

    import gi
    
    gi.require_version('fontconfig', '2.0')
    
    from gi.repository import fontconfig
    
    # you can use fontconfig module now.
    

    I don't know its typelib is complete or not. But you can edit its 'gir' file and contribute back to be usable for a wider audience.