Skip to content

ModuleNotFoundError when saving a plot on Windows #304

@M-Lampert

Description

@M-Lampert

When running pp.plot(g, filename="graph_plot.png") on a Windows machine, you get the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pathpyG\visualisations\plot_function.py:156, in _get_plot_backend(backend, filename, default)
    155 try:
--> [156](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/morit/Desktop/~/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0/LocalCache/local-packages/Python312/site-packages/pathpyG/visualisations/plot_function.py:156)     module = importlib.import_module(f"pathpyG.visualisations._{_backend}.backend")
    157 except ImportError as e:

File C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\importlib\__init__.py:90, in import_module(name, package)
     89         level += 1
---> [90](file:///C:/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0/Lib/importlib/__init__.py:90) return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1310, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1310, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1324, in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'pathpyG.visualisations._Backends'

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
Cell In[3], [line 1](vscode-notebook-cell:?execution_count=3&line=1)
----> [1](vscode-notebook-cell:?execution_count=3&line=1) pp.plot(g, filename="graph_plot.png")

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pathpyG\visualisations\plot_function.py:236, in plot(graph, kind, show_labels, **kwargs)
    233 filename = kwargs.pop("filename", None)
    234 _backend: str = kwargs.pop("backend", None)
--> [236](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/morit/Desktop/~/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0/LocalCache/local-packages/Python312/site-packages/pathpyG/visualisations/plot_function.py:236) plot_backend_class = _get_plot_backend(
    237     backend=_backend, filename=filename, default=config.get("visualisation").get("default_backend")  # type: ignore[union-attr]
    238 )
    240 # Check if backend is d3js and set layout to None if not specifically given as argument
    241 if plot_backend_class == D3jsBackend:

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pathpyG\visualisations\plot_function.py:159, in _get_plot_backend(backend, filename, default)
    157 except ImportError as e:
    158     logger.error(f"The <{_backend}> backend could not be imported.")
--> [159](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/morit/Desktop/~/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0/LocalCache/local-packages/Python312/site-packages/pathpyG/visualisations/plot_function.py:159)     raise ImportError from e
    161 return getattr(module, f"{_backend.capitalize()}Backend")

ImportError:

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions