# Fix "ModuleNotFoundError: No module named 'dash_core_components'"

Yes. An agent moves a Dash 1 app's dcc, html and dash_table imports and run_server to the Dash 3 names, then starts the app in a sandbox to prove the layout loads.

[Run this on Rush](https://cloud.getrush.ai/run/fix-no-module-named-dash-core-components/dash/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

Dash 2 folded the three component packages into the main package and kept stubs for the old names: on 2.18.2, `import dash_core_components as dcc` works and prints `The dash_core_components package is deprecated. Please replace ... with from dash import dcc`, with the same warning for `dash_html_components` and `dash_table`. Dash 3.0.0 dropped the stubs, so on 3.0.0 and the current 4.5.0 each of those imports raises `ModuleNotFoundError`. The same release removed `app.run_server`: on 4.5.0 calling it raises `ObsoleteAttributeException: app.run_server has been replaced by app.run`. `from dash.dependencies import Input, Output, State, ClientsideFunction`, `dash.Dash(__name__, external_stylesheets=[...])` and `dash_table.DataTable` all still work when imported from `dash`.

covid19-dash/covid-dashboard is a Dash app that draws a map and a time series from Johns Hopkins data and is published as static pages. `requirements.txt` pins `dash==1.9.1` and nothing else from the Dash family, so a bump of that one line is enough to lose the stubs. `app.py` lines 15 to 17 import `dash_table`, `dash_html_components as html` and `dash_core_components as dcc`, line 59 builds `dash.Dash(__name__, external_stylesheets=[...])` with three Pure CSS links, lines 74 to 182 are the layout with `dcc.Graph`, `dcc.RadioItems`, `dcc.Store`, `dcc.Markdown` and a `dash_table.DataTable`, and line 222 starts it with `app.run_server(debug=debug)`. The callbacks on lines 189 to 217 are clientside, defined in `assets/callbacks.js`, which is why the `Makefile` can start the app, `wget` the layout and dependencies endpoints and ship the result as HTML; `.circleci/config.yml` and `.github/workflows/deploy.yml` both run `make html` after `pip install -r requirements.txt`.

The agent reproduces before it edits. It installs the pinned 1.9.1 in one virtual environment and the current Dash in another, imports `app` in each, and keeps both results: the first imports, the second stops at line 15 with the title's error. It then rewrites the three imports as `from dash import dcc, html, dash_table`, changes line 222 to `app.run(debug=debug)`, and leaves `dash.dependencies`, the constructor, the layout and the clientside callbacks alone, since each of those was checked against the installed package rather than guessed. `requirements.txt` moves from `dash==1.9.1` to a current pin.

The check that matters for this project is that the app still serves what the `Makefile` scrapes. The agent starts the app in the sandbox with `DEBUG=False`, fetches `/`, `/_dash-layout` and `/_dash-dependencies` the way the `html` target does, and confirms the layout JSON names the `map`, `plot`, `table` and `store` ids the clientside callbacks wire together. Data loading in `data_input.py` fetches from the Johns Hopkins repository through `fetcher.py`; if the sandbox cannot reach it the agent says so and tests the layout with a small stand-in frame instead of inventing a result.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "This Dash app fails with ModuleNotFoundError: No module named 'dash_core_components' after a dependency update. Read requirements.txt and report how dash is specified. In a clean virtual environment install the pinned requirements and import the app; in a second environment install the current dash release and import again, keeping both results. List every import of dash_core_components, dash_html_components and dash_table, every app.run_server call, and every other dash attribute the code uses (dash.dependencies, Dash constructor arguments, clientside_callback) with file and line, and check each against the installed package to decide what must change. Port the imports to from dash import dcc, html, dash_table and run_server to app.run; change nothing that still works. Update the dash pin. Start the app in the sandbox and fetch /, /_dash-layout and /_dash-dependencies the way the Makefile's html target does, and confirm the component ids the clientside callbacks reference are present in the layout. If the data fetch needs network the sandbox lacks, say so and test the layout with a small stand-in dataframe. Open a pull request with the two import results, the list of changed lines, and the output of the three fetches.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that touches the three import lines and the last line of `app.py`, and the `dash` pin in `requirements.txt`. Its description opens with the import that passes on 1.9.1 and the one that fails on the current release, then the list of everything else the file takes from Dash and a line for each saying it was checked and left alone.

The session's record holds the app starting in the sandbox and the three fetches the `Makefile` makes, with the layout JSON showing the `map`, `plot`, `table` and `store` ids. That is the same output the CircleCI and GitHub Actions jobs scrape into static pages, so the reviewer can compare it with the last good build.

Before merging, a reviewer runs `make html` in CI on the branch and opens the generated page, since the clientside callbacks in `assets/callbacks.js` are only exercised in a browser. The pull request says whether the data fetch ran in the sandbox or whether the layout was tested on a stand-in frame.

## Run it on every scheduled build

This dashboard rebuilds itself twice a day: `deploy.yml` runs on a `push` to `master` and on two `cron` lines, installing `requirements.txt` fresh each time. A build that fails on an import is the signal. A handler on your server receives the workflow's failure notification and sends this request with `POST /o/{org}/sessions`, the repository in `resources` and the failing step's log appended to `input`, with a `request_id` that is a UUID v5 of the workflow run id so a retry returns the run already started.

To catch it before the build, an automation on the Project with a `schedule` trigger set a few hours before the deploy's `cron` can run the prompt "install requirements.txt fresh, import the app, and open a pull request only if the import fails" once a day. A run an automation starts has its own `max_runs_per_hour` cap and is read from its session like any other.

## Why run it on Rush?

The failing line is obvious; what the port breaks is not. A Dash app's layout is built from dozens of component calls, and the only way to know they all still resolve is to start the server and fetch the layout, which is exactly what this project's `Makefile` does. The agent does that in a sandbox with two Dash releases installed side by side, and leaves the fetched JSON in the session for the reviewer.

It also scales to the rest of the shelf. Dashboards built on Dash 1 tend to come in sets, one per dataset, each with the same three imports. The same request goes to each repository as its own session, as many at once as the key's `max_concurrent` limit allows, and each pull request carries the fetch output for its own layout.

## Frequently asked questions

### Why does the import work on Dash 2 but not Dash 3?

Dash 2 kept stub packages named `dash_core_components`, `dash_html_components` and `dash_table` that re-export from `dash` and print a deprecation warning; 2.18.2 still does. Dash 3.0.0 removed them, so the old import names raise `ModuleNotFoundError` on 3.0.0 and on 4.5.0.

### Does app.run_server need to change too?

Yes. On 4.5.0 `app.run_server` raises `ObsoleteAttributeException: app.run_server has been replaced by app.run`; on 2.18.2 both exist. The agent changes the one call on line 222 and keeps the `debug` argument.

### Can I keep dash==1.9.1 and ignore this?

The pin is what has kept the project running, and it still installs. The error arrives the moment the pin is bumped or dropped, and the two-line port lets the app track current releases. The pull request moves the pin and the imports together so the build in `deploy.yml` sees one consistent change.

### Will the clientside callbacks keep working?

They are defined in `assets/callbacks.js` and wired with `app.clientside_callback` and `ClientsideFunction`, both still exported by Dash 4. The agent confirms the component ids they reference appear in `/_dash-layout` and leaves the browser check to the reviewer, since the sandbox fetch does not execute them.

### Does the agent need the live COVID data?

Only to reproduce the full build. If `fetcher.py` cannot reach the upstream repository from the sandbox, the request tells the agent to say so and test the layout with a small stand-in frame, and the pull request states which of the two happened.

## More jobs like this: Fix a bug from an alert

- [Fix "ModuleNotFoundError: No module named 'fabric.api'" by Porting a fabfile to Fabric 3](https://getrush.ai/run/fix-no-module-named-fabric-api/fabric/)
- [Fix "ModuleNotFoundError: No module named 'imghdr'" on Python 3.13](https://getrush.ai/run/fix-no-module-named-imghdr/imghdr/)
- [Fix ModuleNotFoundError: No module named 'imp' on Python 3.12](https://getrush.ai/run/fix-no-module-named-imp/imp/)
- [Fix "ModuleNotFoundError: No module named 'imp'" on Python 3.12](https://getrush.ai/run/fix-no-module-named-imp/python/)
- [Fix "ModuleNotFoundError: No module named 'kafka.vendor.six.moves'" on Python 3.12](https://getrush.ai/run/fix-no-module-named-kafka-vendor-six-moves/kafka-python/)
- [Fix "ModuleNotFoundError: No module named 'moviepy.editor'"](https://getrush.ai/run/fix-no-module-named-moviepy-editor/moviepy/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
