plotly / plotly/dash

Dash on Windows crashes with Syntax Error due to forward slash in Windows path

Open
#3,002 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

I did a Quick-Fix to solve this issue for myself (see below), but I like to share my findings here and give opportunity to fix this properly.

Describe your context
I run JupyterLab Desktop on Windows 11 (64-bit)

Then I import dash like so:

from dash import Dash
from dash import dcc, html
from dash.dependencies import Input, Output
import plotly.express as px

Output of pip list is:

dash                      2.18.1
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0

Describe the bug
As soon as I run : app.run_server(mode='inline') an error is thrown with message:

[2024-09-13 15:41:45,496] ERROR in app: Exception on /_alive_0ded12ab-0b05-44c0-a874-6b2a8c7f5800 [GET]
Traceback (most recent call last):
File "\?[C:\Users\Gebruiker\AppData\Roaming\jupyterlab-desktop\jlab_server\Lib\site-packages\flask\app.py", line 1473](file:///C:/Users/Gebruiker/AppData/Roaming/jupyterlab-desktop/jlab_server/Lib/site-packages/flask/app.py#line=1472), in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

... ...

File "\?[C:\Users\User\AppData\Roaming\jupyterlab-desktop\jlab_server\Lib\site-packages\dash\dash.py", line 844](file:///C:/Users/Gebruiker/AppData/Roaming/jupyterlab-desktop/jlab_server/Lib/site-packages/dash/dash.py#line=843), in _relative_url_path
modified = int(os.stat(module_path).st_mtime)
^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 123] The syntaxis of filename, folder name or volume name is incorrect: '\\?\C:\Users\Gebruiker\AppData\Roaming\jupyterlab-desktop\jlab_server\Lib\site-packages\dash\deps/polyfill@7.12.1.min.js'

And then an Internal Server Error

Expected behavior
At least not an error, I expect a nice chart or so

Quick Fix

As I have a local installation on my Windows PC, I fixed the problem by bluntly replacing the forward slash (/) with an escaped backslash:

in 'dash.py' I added in line 840:
relative_package_path = relative_package_path.replace("/", "\\")

If applicable, add screenshots or screen recording to help explain your problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in dash.py around line 844, where _relative_url_path calls os.stat(module_path), and reproduce the Windows failure with app.run_server(mode='inline'). Trace how the relative package path becomes the malformed Windows path shown in the traceback; done means the inline app runs without WinError 123 and displays its chart.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, jupyter, python
Domain
backend, data-visualization, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.