Pyecharts is a powerful and flexible Python library designed to generate interactive ECharts-based visualizations. It provides a Pythonic interface to over 30 chart types, making it easier to create stunning and interactive data visualizations for web pages, Jupyter notebooks, and other Python frameworks. The library is actively maintained, with the current stable version being 2.1.0, released in February 2026, and regular updates incorporating new ECharts features.
pip install pyechartsVerified import paths — ran on the pinned version, not inferred.
This quickstart code creates a simple interactive bar chart using Pyecharts, adds two data series, and saves the chart as an HTML file named 'my_first_chart.html' in the current directory. This HTML file can then be opened in any web browser.
Review chart configurations and ECharts 6.x upgrade guide for changes in default themes, component positioning, and API updates. For styling, explicit `theme_opts` and `pos_top`, `pos_left` for legends can help restore previous layouts. The original ECharts documentation provides detailed migration steps from v5 to v6.
Ensure your Python environment is version 3.7 or higher. Upgrade Python if necessary, or use a virtual environment with a compatible Python version.
Install the relevant map data package using pip, for example, `pip install echarts-countries-pypkg` for world maps or `echarts-china-provinces-pypkg` for Chinese provincial data.
Install `pyecharts-snapshot` (`pip install pyecharts-snapshot`) and its chosen backend (e.g., `pip install snapshot-pyppeteer` and ensure Node.js is installed on your system).
Convert `numpy` arrays or `pandas` Series/DataFrames to standard Python lists before passing them to `pyecharts` chart methods (e.g., `add_xaxis(data.tolist())`, `add_yaxis(name, values.tolist())`).
Use `chart.render_notebook()` for Jupyter environments. When generating standalone HTML files, be aware of the `is_embed_js` option on `Page` and `InitOpts` for controlling JavaScript embedding for offline access or smaller file sizes.
Install the library using pip: `pip install pyecharts`
Import chart types from `pyecharts.charts`: `from pyecharts.charts import Bar` (replace `Bar` with the desired chart type). You might also need to import `options` from `pyecharts` as `from pyecharts import options as opts`.
Ensure you are using the correct import paths for utility functions or specific modules. For common configurations, import `options` as `from pyecharts import options as opts`. If 'utils' is specifically needed, it might be in `pyecharts.commons.utils` or its functionality has been absorbed elsewhere.
For Jupyter Notebooks, use the `.render_notebook()` method: `chart.render_notebook()`. For saving to an HTML file, use `chart.render('your_chart.html')`. Ensure `CurrentConfig.NOTEBOOK_TYPE` is set correctly if you are in environments like Jupyter Lab or VS Code Notebooks: `from pyecharts.globals import CurrentConfig, NotebookType; CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB` (adjust `NotebookType` as needed).Install `pyecharts-snapshot` and ensure a compatible headless browser driver (e.g., `chromedriver-py`) is available: `pip install pyecharts-snapshot chromedriver-py`.