Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import st_navbar from streamlit_navigation_bar #18

Closed
4 tasks done
Anthony-Lannes opened this issue Jan 20, 2025 · 6 comments
Closed
4 tasks done

Cannot import st_navbar from streamlit_navigation_bar #18

Anthony-Lannes opened this issue Jan 20, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@Anthony-Lannes
Copy link

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Streamlit immediately reports an error after the line : "from streamlit_navigation_bar import st_navbar".
It appears even in a brand new venv with only streamlit and streamlit-navigation-bar.

Reproducible code example

import streamlit as st
from streamlit_navigation_bar import st_navbar


page = st_navbar(["Home", "Documentation", "Examples", "Community", "About"])
st.write(page)

Steps to reproduce

Create a new project (I used PyCharm)
Setup a new virtual environment using venv
Create a new file with the code provided (the same as the first example provided in readme)
Run the script

Expected behavior

The same as the first example provided in readme.

Current behavior

Error Message :

"""
streamlit.errors.StreamlitAPIException: No such component directory: 'C:\path_to_my_project\venv\Lib\site-packages\streamlit_navigation_bar\frontend\dist'

Traceback:
File "C:\path_to_my_project\venv\Lib\site-packages\streamlit\runtime\scriptrunner\exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File "C:\path_to_my_project\venv\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 579, in code_to_exec
exec(code, module.dict)
File "C:\path_to_my_project\test_navbar\test.py", line 5, in
from streamlit_navigation_bar import st_navbar
File "C:\path_to_my_project\venv\Lib\site-packages\streamlit_navigation_bar_init_.py", line 33, in
_st_navbar = components.declare_component(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\path_to_my_project\venv\Lib\site-packages\streamlit\components\v1\component_registry.py", line 115, in declare_component
get_instance().component_registry.register_component(component)
File "C:\path_to_my_project\venv\Lib\site-packages\streamlit\components\lib\local_component_registry.py", line 52, in register_component
raise StreamlitAPIException(f"No such component directory: '{abspath}'")
"""

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.41.0
  • Streamlit Navigation Bar version: 4.0.7
  • Python version: 3.12.6
  • Operating System: Microsoft Windows [version 10.0.22631.3880]
  • Browser: Bing

Additional information

No response

@Anthony-Lannes Anthony-Lannes added the bug Something isn't working label Jan 20, 2025
@hansthen
Copy link
Contributor

Unfortunately, when I started working on this package, I uploaded a few broken versions. Can you upgrade the latest version and see if that solves the issue? I made no backwards incompatible changes to the package.

@BarryDigby
Copy link

Hi Hans,

Following up on the above re. installation issues. I'm using code from example 2 to test the installation.

I have installed the package using pip install streamlit-community-navigation-bar==4.3.0.

When launching the application, I'm faced with this error:

streamlit.errors.StreamlitAPIException: No such component directory: 'C:\Users\DIGBYB\github\pymde_hub\.venv\lib\site-packages\streamlit_navigation_bar\frontend\dist'

I then install Gabriel's version of the package to satisfy this error using pip install streamlit-navigation-bar as I know it will correctly populate the component directory reported above.

The application now launches, but I run into the issues 27 and 28 reported on Gabriel's repository.

This would suggest the application is favouring the use of Gabriel's code (and the old base.css file) which makes the navigation bar not show correctly over your updated code.

I have also tested installation using pip install streamlit-community-navigation-bar@git+https://github.com/streamlit-community/streamlit-navigation-bar.git to use version 4.4.0 of this repository, but the same behaviour occurs.

Am I making a mistake during installation? Any advice is much appreciated.


Versions

Python: 3.10.0
Streamlit: 1.41.1
streamlit-community-navigation-bar: 4.3.0, 4.4.0
streamlit-navigation-bar: 3.3.0

@duarteharris
Copy link

First off: thank you @hansthen for picking this back up.

I'm also running into this. Any updates?

@hansthen
Copy link
Contributor

hansthen commented Jan 25, 2025

There is still an error with the automated build that I need to fix. I manually uploaded a new version (4.4.1) that will work. I will do some trial runs to see if I can fix the build. In case you run in trouble just use pip install streamlit-community-navigation-bar==4.4.1.

Please also ensure that you uninstall the old streamlit-navigation-bar to avoid any conflicts.

@BarryDigby
Copy link

@hansthen thank you for the fix, 4.4.1 working now!

@Anthony-Lannes
Copy link
Author

@hansthen It definitely solve the issue. Sorry for not testing earlier, I was kinda busy last week.
Also, as mentionned by @duarteharris, thank you very much for taking the project on. This feature is awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants