No module named 'segment.analytics' / from pygwalker.api.streamlit import StreamlitRenderer

dear sir
I am encountering an issue with my straightforward code that utilizes PyGWalker in conjunction with Streamlit. When I attempt to execute it, I receive an error related to the library:

from pygwalker.api.streamlit import StreamlitRenderer
The error message states: “ModuleNotFoundError: No module named ‘segment.analytics’.”
I would appreciate your guidance in resolving this matter.

see my code

import streamlit as st
from pygwalker.api.streamlit import StreamlitRenderer
import pandas as pd
df = pd.read_csv(“c:\iqra\mfa.csv”)
pyg_app = StreamlitRenderer(df)
pyg_app.explorer()

see error
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\streamlit\runtime\scriptrunner\exec_code.py”, line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\streamlit\runtime\scriptrunner\script_runner.py”, line 579, in code_to_exec
exec(code, module.dict)
File “C:\mfa\pygwnew.py”, line 1, in
from pygwalker.api.streamlit import StreamlitRenderer
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pygwalker_init_.py”, line 16, in
from pygwalker.api.jupyter import walk, render, table
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pygwalker\api\jupyter.py”, line 6, in
from .pygwalker import PygWalker
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pygwalker\api\pygwalker.py”, line 29, in
from pygwalker.services.upload_data import (
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pygwalker\services\upload_data.py”, line 9, in
from pygwalker.communications.base import BaseCommunication
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pygwalker\communications\base.py”, line 4, in
from pygwalker.services.track import track_event
File “C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pygwalker\services\track.py”, line 3, in
import segment.analytics as analyti

This looks like an issue with your PyGWalker installation. If you follow the stack trace, PyGWalker is trying to use the segment library. You can try to install Segment yourself (check PyGWalker for the right version), but I’d be inclined to create a clean Python environment and use it to pip install streamlit pygwalker to make sure you have a clean install.

So basically, this is an issue with PyGWalker instead of Streamlit at the moment. :slight_smile:

Edit: I see someone else is asking about this same thing, so there may be a misconfiguration in PyGWalker’s setup script, which means you’d need to manually install Segment either way.