Skip to content

Different import name and package name breaks a new app #133

Open

Description

@vijote

Hello everyone, hope you're doing fine!

I'm trying to generate a new streamlit app with this template, to include my own custom components, and I've found that when the package_name is different than the import_name on the CLI, when running the app it shows the error:

streamlit.errors.StreamlitAPIException: Component 'streamlit-template.custom_components' must be declared in pyproject.toml with asset_dir to use file-backed js.

Here are the steps I've executed on the CLI:
[1/8] author_name (John Smith):
[2/8] author_email (john@example.com):
[3/8] project_name (Streamlit Component X): my streamlit app
[4/8] package_name (my-streamlit-app):
[5/8] import_name (my_streamlit_app): custom_components
[6/8] description (Streamlit component that allows you to do X):
[7/8] Select open_source_license
1 - MIT
2 - BSD-3-Clause
3 - ISC
4 - Apache-2.0
5 - GPL-3.0-or-later
6 - LicenseRef-Proprietary
Choose from [1/2/3/4/5/6] (1):
[8/8] Select framework
1 - React + Typescript
2 - Pure Typescript
Choose from [1/2] (1):

And after having the folders ready I did:

cd my-streamlit-app
uv venv
source .venv/bin/activate
cd ./custom_components/frontend/ && npm i && npm run build
cd ../..
uv pip install -e .
python3 -m streamlit run ./example.py

And faced the error.

I think this has to do with some missing configuration on the template.
Any help to fix the error will be appretiated!

Activity

  1. changed the title [-]Using different import name than package[/-] [+]Different import name and package name breaks a new app[/+] on Dec 17, 2025
  2. sfc-gh-bnisco commented on Dec 19, 2025

    @sfc-gh-bnisco
    Contributor

    Thanks @vijote for the message!

    Can you scaffold this again but ensure that the import name matches the package name? So in this case, it should be my-streamlit-app/my_streamlit_app, rather than my-streamlit-app/custom_components. That should work, let me know, thanks!

  3. vijote commented on Dec 19, 2025

    @vijote
    Author

    Hi @sfc-gh-bnisco , thanks for the response.

    I did that before and it worked. I'm interested in using this with a different folder name, and I'm not a frequent python user so maybe it's something I'm not familiar with.
    Is there a reason why the options in the scaffolding can't be changed? I mean I can only specify a project name and leave the rest as is.

  4. mp-mech commented on Apr 2, 2026

    @mp-mech

    I also experience this issue, and I agree with @vijote, the fact that we need to keep the naming consistent across project_name, package_name and import_name makes the questions useless and prone to errors.
    Is this behavior intended ? If not do you have an idea of the origin of it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions