Skip to content

FontError list of missing fonts in mainwindow.py is incomplete #26143

Description

@Boohoolean

I recently ran into a problem starting Spyder 6.1.5 on a Windows 11 system configured to block untrusted fonts, with a user account that lacks font installation rights.
This situation triggers the FontError exception in mainwindow.py (image),
Image
however the list of fonts it provides is incomplete.
Installing all of the listed fonts for all users therefore does not resolve the issue, and spyder will still refuse to start.

To troubleshoot the issue I added the below to the FontError function:
import traceback; traceback.print_exc()
and launched Spyder through spyder-script.pyw to obtain the below error output in the console:

(spydertest) C:\Users\Username1>python "C:\Users\Username1\AppData\Local\miniconda3\Scripts\spyder-script.pyw"
ARB::createContext: wglCreateContextAttribsARB() failed (GL error code: 0x0) for format: QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::DefaultSwapBehavior, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile), shared context: 0x0 (The operation completed successfully.)
GDI::createContext: wglCreateContext failed. (The operation completed successfully.)
Unable to create a GL Context.
Traceback (most recent call last):
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\app\mainwindow.py", line 1401, in main
    mainwindow = create_window(MainWindow, app, splash, options, args)
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\app\utils.py", line 360, in create_window
    main.setup()
    ~~~~~~~~~~^^
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\app\mainwindow.py", line 691, in setup
    internal_plugins = find_internal_plugins()
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\app\find_plugins.py", line 45, in find_internal_plugins
    mod = importlib.import_module(entry_point.module)
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\importlib\__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1023, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\plugins\pylint\plugin.py", line 25, in <module>
    from spyder.plugins.pylint.confpage import PylintConfigPage
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\plugins\pylint\confpage.py", line 16, in <module>
    from spyder.plugins.pylint.main_widget import (MAX_HISTORY_ENTRIES,
                                                   MIN_HISTORY_ENTRIES,
                                                   PylintWidget)
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\plugins\pylint\main_widget.py", line 94, in <module>
    class CategoryItem(QTreeWidgetItem):
    ...<42 lines>...
            self.setIcon(0, icon)
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\plugins\pylint\main_widget.py", line 106, in CategoryItem
    'icon': ima.icon("convention")
            ~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\utils\icon_manager.py", line 466, in icon
    qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json',
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                directory=self._resource['directory'])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\qtawesome\__init__.py", line 314, in load_font
    return _instance().load_font(prefix, ttf_filename, charmap_filename, directory)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\qtawesome\iconic_font.py", line 432, in load_font
    raise FontError(
    ...<8 lines>...
    )
qtawesome.iconic_font.FontError: Font at 'C:\Users\Username1\AppData\Local\miniconda3\Lib\site-packages\spyder\utils\../fonts\spyder.ttf' appears to be empty. If you are on Windows 10, please read https://support.microsoft.com/en-us/kb/3053676 to know how to prevent Windows from blocking the fonts that come with QtAwesome.

I believe the issue lies in utils\icon_manager.py attempting to load an additional font that is not listed in the original error message, by calling

qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json',
                                directory=self._resource['directory'])

For systems set up to block untrusted fonts, this will fail, but the generated error message does not provide useful information to help the user resolve the issue.
After installing the spyder.ttf font for all users, the error message no longer appears, and Spyder loads successfully.
I therefore believe that the original list of fonts, and the folder from which they should be installed, is incomplete and needs correction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions