Ensure you have Python 3.11.7 installed. If not, you can install it using pyenv.
To install pyenv
, run the following commands:
curl https://pyenv.run | bash
Then, add the following lines to your shell configuration file (~/.bashrc
, ~/.zshrc
, or ~/.profile
):
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
Apply the changes:
source ~/.bashrc # or source ~/.zshrc
To install Python 3.11.7 using pyenv
, run:
pyenv install 3.11.7
pyenv global 3.11.7
pyenv rehash
Verify the installation:
python --version
Before proceeding, clone the filterpy
repository:
git clone https://github.com/rlabbe/filterpy.git
-
Create and activate a virtual environment:
python -m venv myenv source myenv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the main script:
uvicorn api.server:app --host 0.0.0.0 --port 8000 --reload
You can easily run this project using Docker. Follow the steps below to build and run the application in a containerized environment.
-
Prerequisites
- Docker installed on your machine
-
Build the Docker Image
docker build -t gate-guard-ai .
This will:
- Use Python 3.11-slim as a base
- Copy your project files into the container
- Install required system dependencies (
libgl1
,libglib2.0-0
) - Install Python dependencies from
requirements.txt
-
Run the Docker Container
docker run -p 8000:8000 gate-guard-ai
This starts the FastAPI server using
uvicorn
on port8000
.You can now access your API at: http://localhost:8000
-
Auto-Reload (Development Mode)
To enable live reloading (already enabled via
--reload
in CMD), make sure you mount your local volume like this:docker run -p 8000:8000 -v ${PWD}:/app gate-guard-ai
Changes made to the code will automatically reflect inside the container.
Would you like me to generate a
docker-compose.yml
file for easier multi-container setup or add examples for endpoints in FastAPI?
If you encounter this error, install the missing dependencies:
sudo apt update && sudo apt install -y \
libbz2-dev \
libssl-dev \
libreadline-dev \
libsqlite3-dev \
libffi-dev \
liblzma-dev \
zlib1g-dev \
libncursesw5-dev \
xz-utils \
tk-dev
If the issue persists, reinstall Python 3.11.7 using pyenv:
pyenv install 3.11.7 --force
pyenv local 3.11.7
pyenv rehash
To ensure the virtual environment is up to date:
source myenv/bin/activate
python -m venv myenv --upgrade
Now, your environment should be properly configured and ready to use! 🚀