tiangolo / full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backend container: module 'h11' has no attribute 'Event'

Rokulus opened this issue · comments

Hello, anybody had a problem when starting with docker-compose up -d that container for backend write out error:

user@user-machine:~/Desktop/generated_project/fastapi$ sudo docker run backend:latest

Checking for script in /app/prestart.sh
Running script /app/prestart.sh
Traceback (most recent call last):
File "/app/app/backend_pre_start.py", line 5, in
from app.db.session import SessionLocal
File "/app/app/db/session.py", line 4, in
from app.core.config import settings
File "/app/app/core/config.py", line 7, in
class Settings(BaseSettings):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.new
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.init
File "pydantic/fields.py", line 557, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 831, in pydantic.fields.ModelField.populate_validators
File "pydantic/networks.py", line 591, in get_validators
File "pydantic/networks.py", line 578, in pydantic.networks.import_email_validator
File "/usr/local/lib/python3.7/site-packages/email_validator/init.py", line 6, in
import dns.resolver
File "/usr/local/lib/python3.7/site-packages/dns/resolver.py", line 39, in
import dns.query
File "/usr/local/lib/python3.7/site-packages/dns/query.py", line 58, in
import httpx
File "/usr/local/lib/python3.7/site-packages/httpx/init.py", line 2, in
from ._api import delete, get, head, options, patch, post, put, request, stream
File "/usr/local/lib/python3.7/site-packages/httpx/_api.py", line 4, in
from ._client import Client
File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 29, in
from ._transports.default import AsyncHTTPTransport, HTTPTransport
File "/usr/local/lib/python3.7/site-packages/httpx/_transports/default.py", line 30, in
import httpcore
File "/usr/local/lib/python3.7/site-packages/httpcore/init.py", line 1, in
from ._api import request, stream
File "/usr/local/lib/python3.7/site-packages/httpcore/_api.py", line 5, in
from ._sync.connection_pool import ConnectionPool
File "/usr/local/lib/python3.7/site-packages/httpcore/_sync/init.py", line 1, in
from .connection import HTTPConnection
File "/usr/local/lib/python3.7/site-packages/httpcore/_sync/connection.py", line 13, in
from .http11 import HTTP11Connection
File "/usr/local/lib/python3.7/site-packages/httpcore/_sync/http11.py", line 44, in
class HTTP11Connection(ConnectionInterface):
File "/usr/local/lib/python3.7/site-packages/httpcore/_sync/http11.py", line 140, in HTTP11Connection
self, event: h11.Event, timeout: Optional[float] = None
AttributeError: module 'h11' has no attribute 'Event'

I find solution that I need to install pip install --force-reinstall httpcore==0.15 but I don't know how to install it inside stopped container or where to write this line during installation of backend container

Did anyone had this problem ? Every help will be appreciated and thank you in advance

I figured it out.

You have to add this line in file /backend/app/pyproject.toml in [tool.poetry.dependencies]
httpcore = "0.10"

Then it's working properly.

For those rookies like me who is seeing the above resolution, update the poetry lock file before building the container again.

i.e. go to the path of toml file above, activate the venv and run command "poetry lock"