When you change Plotly's own source code and need the modified library to run, build the plotly package from its repository and make your environment import that build instead of a preinstalled release. The key condition is matching your toolchain to the branch: Plotly's Python library historically used a combination of JavaScript bundling (via npm) and Python packaging (via setuptools), and recent major versions moved the Python source into a pyproject.toml-driven layout. Before you touch your code, confirm which of those layouts your checkout uses; the bundle-and-install sequence differs, and running the wrong one wastes time on failures that look like code bugs.
This guide walks through the order that works: inspect the repository, set up tooling, rebuild bundled JavaScript assets, reinstall the Python package in editable mode, verify the change is actually live, and only then debug. Everything here is stable knowledge about how Plotly-style Python/JavaScript hybrid packages are assembled; exact script names and dependency versions change between Plotly releases, so treat command names as patterns to confirm in the repository's own package.json and packaging files rather than fixed incantations.
First determine which Plotly generation you are building
Plotly has shipped two meaningfully different repository shapes, and "how to build" depends on which one you have. Older releases (roughly the 3.x and 4.x eras, and early 5.x) keep Python code in a plotly/ directory at the repo root with a setup.py, and they expect JavaScript assets to be generated with npm scripts (historically npm run build or a build: variant) into a package folder such as plotly/package_data/. Starting with Plotly 6.0, the project moved to a standard src/plotly Python source layout with pyproject.toml and an optional companion package, plotly[express], for Plotly Express dependencies. If you clone or download the repository at the version matching your modification, the presence or absence of pyproject.toml and a src/ directory tells you which layout you're working in almost immediately.
The distinction matters because the two layouts place the importable package in different directories, so an editable install performed against the wrong root can appear to "work" while importing the old site-packages copy. It also changes how asset builds are wired: in the modern layout, the JavaScript build outputs are still expected under the Python package's data directory (for example src/plotly/package_data/), but Python-level configuration lives in pyproject.toml and the build backend rather than in a root setup.py.
Do this check before anything else, and write down the version. If your checkout is a release tag like a 5.x branch, follow the older instructions; if it's 6.x or later, the modern instructions apply. Mixing instructions across the divide is the single most common reason a rebuild seems to succeed but the browser still renders unmodified behavior.
The other prerequisite is deciding why you're building. If you changed Python-side behavior (for example the validation logic in a chart object, default layout handling, or how a figure serializes to JSON), you generally do not need to rebuild JavaScript at all; reinstalling the Python package in editable mode is enough. If you changed anything in the JavaScript rendering layer, the Plotly.js schema used to generate Python classes, or a template or asset consumed by the front end, you must rebuild the bundle. Sorting that out early prevents you from spending twenty minutes on npm for a change that only touches Python code.
Prerequisites before you run any build command
Set up the environment so a failed rebuild doesn't damage a working install you depend on. Use a virtual environment (venv or conda) dedicated to this checkout rather than your system Python or the environment that runs production notebooks.
You need a Python version compatible with the checkout's packaging metadata. For modern Plotly (6.x and later), the declared minimum is Python 3.8 or newer; older 4.x/5.x branches supported older interpreters, but if you're modifying a 2026-era checkout, assume a current Python 3 release is expected. Confirm by reading requires-python in pyproject.toml or python_requires in setup.py.
You need Node.js and npm if and only if you're rebuilding JavaScript assets. Plotly's assets are built with a Node toolchain; a modern LTS Node release is the safe choice. Check the engines field in the repository's package.json for any pinned minimum. Also plan for a clean install: run npm install (or npm ci if the repo commits a lockfile and the package manager supports it) from the repository root, because a half-populated node_modules produces confusing bundler errors.
Finally, know your build backend. Modern Plotly packages build with setuptools through pyproject.toml; installing with pip install -e . from the repository root invokes that backend. You do not need to install setuptools manually in a current environment, since pip provisions build backends in isolated build environments by default.
Back up state and capture a reproducible baseline
Before rebuilding, confirm the current environment imports the version you think it does. Run a short Python check that prints plotly.version and, more importantly, the module file path (plotly.file). Save that output. After the rebuild, the path should point into your checkout (for an editable install) or into the environment's site-packages for a freshly installed build, and the version string should reflect your branch — for example, a development suffix if the checkout's version metadata says so.
Also record what you changed. A rebuild that fails after several edits is much harder to diagnose than one that fails after a single change, and you'll want to be able to revert. If your modification touched generated files (many schema-derived Python modules in Plotly are code-generated), note that regenerating them will overwrite your edits unless the generator input (the schema JSON) was changed instead. This is the most common silent failure in Plotly-style repositories: you edit a generated .py file by hand, then a rebuild or codegen step rewrites it and your change vanishes.
As a success check baseline, run one tiny figure through the code path you changed and save its output. For a front-end change, that means rendering in a browser or Jupyter environment where you can see the actual plot, not just a successful Python import.
Reinstall the Python package in editable mode
For Python-only changes, or after the JavaScript bundle exists, install the checkout so the environment imports your local source. From the repository root:
1: Activate the dedicated virtual environment. 2: Run pip install -e . (the editable flag), adding the extra only if your code path needs Plotly Express: pip install -e ".[express]". 3: Wait for the build backend to finish and watch for errors about missing files under the package data directory. 4: Re-run the version/path check and confirm the import resolves to your checkout.
Expect editable installs to expose the source directory. Modern builds using src/ layout place the importable package under src/plotly, and the editable install wires imports to that path; an older layout exposes the root plotly/ directory. If plotly.file still points at a preinstalled copy elsewhere, you likely have a second installation shadowing the editable one — uninstall the previous plotly package from the environment and repeat.
The stop condition for this step: if installation fails because a required generated file is genuinely absent and you did not delete it yourself, do not start hacking the build backend. That usually means the checkout is incomplete (for example a source archive missing bundle artifacts, or a git clone where a submodule or LFS asset wasn't fetched). Restore a complete checkout before continuing.
Rebuild the JavaScript assets when the front end changed
If your change affects rendering, run the repository's asset build. The pattern is consistent even though the exact script name varies by release:
1: From the repository root, install Node dependencies: npm install (or npm ci with a committed lockfile). 2: List the available scripts (npm run with no argument prints them) and locate the one that builds the distributable assets — names like build, build:plotly, or a task that compiles the schema and bundles JavaScript into the package data directory. 3: Run that script and let it complete; watch for schema or bundler errors rather than warnings about optional dependencies. 4: Confirm output: check that the asset files under the Python package's data directory have fresh timestamps, and that any generated JavaScript or JSON schema file changed if your edit should have changed it. 5: Reinstall the Python package (pip install -e . again) so the freshly built assets are packaged into the importable module, because editable installs can cache package data paths.
If you're on a modern checkout and the build script writes into src/plotly/package_data/, the subsequent editable reinstall is usually enough; there's no separate "copy assets" step because the build target already lives inside the Python package tree. In older layouts the assets similarly land in plotly/package_data/. Either way, the check is the same: the files you expect to change should be newer than the build start time and non-empty.
One subtlety: if your change is to source JavaScript that the bundler minifies or tree-shakes, verify behavior using the built artifact, not the source file. A source edit that the bundler discards as dead code will look fine in the diff and do nothing at runtime. If output doesn't reflect your change, broaden the check — confirm the bundle contains a unique string from your edit (search the built file for it) before assuming the Python side is at fault.
Verify that your build is actually live
Do not trust "install succeeded" as the success signal. Confirm with a test that exercises your specific change, and use multiple checks when the change spans Python and JavaScript.
For a Python-side change, import Plotly from the environment, construct the object or call the function you modified, and assert the new behavior directly. Confirm the module path points into the checkout as noted earlier. For a serialization or schema change, generate a figure and inspect the resulting JSON or the generated Python class signature — does it contain the new default, key, or method you added?
For a JavaScript or rendering change, the reliable check is visual and environmental: render in a real browser context (a notebook front end or an exported HTML file opened in a browser). Compare against a screenshot of the pre-change baseline. If you built assets, also confirm the served or embedded asset file is the rebuilt one — caching in the browser or notebook front end can keep an old bundle alive even after a correct rebuild, so do a hard refresh or open a fresh session before concluding anything.
A compact success matrix helps separate causes. If the module path points to your checkout and a Python-level assertion passes but the plot looks unchanged, the problem is almost certainly the JavaScript asset build or a stale cache, not your Python edit. If the assertion fails, the Python reinstall didn't take effect or the source edit was overwritten by codegen. If both fail together, your environment is importing a different installation entirely.
Troubleshooting symptoms and their likely causes
Start with reversible checks, and avoid "fixing" the build by editing generated files.
The import still points to site-packages. Symptom: plotly.file shows an installed copy. Likely cause: multiple installations or an activate/venv mismatch. Reversible check: pip show plotly to see the recorded location, then uninstall from the active environment and reinstall editable. If two environments are mixed, recreate the venv rather than patching paths.
Assets are missing after install. Symptom: build succeeds but packaging errors on missing package_data, or the plot renders blank in the browser. Likely cause: JavaScript build not run, or run against the wrong layout directory. Reversible check: list the package data directory; if the expected bundle files are absent, rerun npm install then the asset script, and reinstall. If the directory exists but a schema or asset file is stale, timestamp comparison catches it.
Your edit disappeared from the source tree. Symptom: the diff you made is gone after a build. Likely cause: a codegen step regenerated the file from a schema. Reversible check: restore the file from your backup or version control, then decide whether the edit belongs in the generator input instead. This is not something to work around by disabling codegen locally, because the next clean build reintroduces the loss.
The browser renders old behavior despite a fresh build. Symptom: Python checks pass, built asset files are fresh, but output is stale. Likely cause: front-end caching (notebook output cache, browser cache, or an HTML file still loading an externally referenced old bundle). Reversible check: open a new browser session or hard-refresh, embed assets rather than referencing remote ones, and confirm in the network panel that the loaded bundle file is the one you built.
Node dependency failures block the asset build. Symptom: npm install or the build script fails on native modules or version conflicts. Likely cause: Node version outside the supported range or a stale/incomplete dependency tree. Reversible check: use a current LTS Node release in a clean checkout, delete node_modules and reinstall from the lockfile. If the failure persists with an officially supported Node version and an unmodified dependency manifest, that's the stop condition: treat it as an environment/project issue and seek guidance from the project's issue tracker or your team's build engineering rather than forcing an unsupported toolchain.
Editable install behaves inconsistently between runs. Symptom: sometimes the checkout's code runs, sometimes a packaged copy. Likely cause: duplicate installs (a preinstalled wheel plus the editable install) or an environment tool that resolves imports differently. Reversible check: rebuild a clean virtual environment and install only the editable checkout into it. This avoids the pathology rather than debugging it.
What counts as a finished rebuild
A finished rebuild has three verifiable facts: the environment imports Plotly from your checkout, the modified behavior (Python-level or rendered output) differs measurably from your saved baseline, and the difference is reproducible in a fresh session after any caching clears. If you can't demonstrate the third, the change isn't really verified. Keep the baseline artifacts until you can.
A complete rebuild also leaves the repository clean. If codegen overwrote files, restore them from version control and move your change to the generated input rather than letting the working tree pick up noise. If you built JavaScript assets, expect generated files to show as modified or untracked; work out from version control which of those are build products that should be ignored and which are checked in by the project.
Finally, note what you had to install and any version-sensitive choices (Node release, Python version, whether the express extra was needed). If you need to rebuild after a second change later, reproducing the exact toolchain takes minutes instead of a fresh investigation, and it makes the build result defensible if a teammate can't reproduce it.
A worked example of sequencing the steps
Suppose you changed how Plotly defaults a figure's internal layout behavior and, separately, adjusted a source template used by the editor front end. Do it in this order: install Node dependencies and run the asset build first (so the package data directory contains the new bundle), then pip install -e . into your dedicated venv, then run the two verification checks — a Python assertion for the layout default, and a browser render with a fresh session for the editor template. If the render is stale while the assertion passes, trust the reverse order principle from the troubleshooting section: check caching, then confirm a unique string from your bundle edit is present in the built asset. Only after both checks pass do you clean up generated files and commit.
That order reflects the real dependency: JavaScript build output is inside the Python package tree, so the Python install must happen after the assets are regenerated, not before. Reversing the sequence is a common mistake that produces a "successful" editable install whose package data snapshot predates the bundle update — which is exactly the failure that looks like a stubborn browser cache but isn't.
Scope limits worth understanding
All of the above concerns building the open-source Plotly Python package from a source checkout. If you're using Plotly through a managed cloud service or a platform notebook that controls its own installed version, your local editable build may not be what the platform executes — in that case, platform-specific environment injection or version pinning is the relevant mechanism, and you should confirm which import path the managed environment actually uses before blaming the build.
Nothing here replaces reading the checkout's own pyproject.toml, package.json, and build scripts. Command names, supported Node and Python versions, and the package data directory change across Plotly releases, and a pinned release's documentation states its exact expectations. Use this guide for the order of operations and the verification discipline; use the repository's own files for exact values, and check the build's success through behavior rather than through console output alone.