Skip to content

Streamlit install

0

i can install streamlit on a lightsail instance using the usual pip install streamlit. I want to replicate this on an EC2 instance. The ec2 instaance uses aws python installation packages. Is there a streamlit installation using the aws python package manager. """ pip install streamlit error: externally-managed-environment

× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. """ Is there a streamlit alternative using the method.

asked a year ago335 views

1 Answer
2

There isn't a specific AWS Python package manager for installing Streamlit on an EC2 instance. The error you're encountering suggests that you're trying to install Streamlit in a system-managed Python environment, which is not recommended.

Instead, to install Streamlit on an EC2 instance, you should follow these best practices:

  1. Create a virtual environment: This isolates your project dependencies from the system-wide Python installation. You can create a virtual environment using:

    python3 -m venv venv

  2. Activate the virtual environment:

    source venv/bin/activate

  3. Upgrade pip within the virtual environment:

    python3 -m pip install --upgrade pip

  4. Install Streamlit using pip within the activated virtual environment:

    pip install streamlit

This approach allows you to install and use Streamlit without interfering with the system-managed Python packages.

If you prefer not to use a virtual environment, you could consider using the --user flag with pip to install Streamlit for the current user only:

pip install --user streamlit

However, using a virtual environment is generally recommended as it provides better isolation and management of dependencies.

Remember to configure your EC2 instance's security group to allow inbound traffic on the port Streamlit uses (default is 8501) if you want to access the Streamlit application from outside the instance.

Sources
How LotteON built dynamic A/B testing for their personalized recommendation system | AWS Machine Learning Blog
AWS Glue Visual ETL - Install/ import packages | AWS re:Post
Automate invoice processing with Streamlit and Amazon Bedrock | AWS Machine Learning Blog

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.