xtekky/gpt4free · warning · MissingRequirementsError
Install "beautifulsoup4" requirements | pip install -U g4f[f
Error message
Install "beautifulsoup4" requirements | pip install -U g4f[files]
What it means
supports_filename raises MissingRequirementsError for .html files when beautifulsoup4 is not importable. HTML files are only accepted as parseable attachments if BeautifulSoup is available to sanitize/extract them.
Source
Thrown at g4f/tools/files.py:145
f'Install "pypdf2" requirements | pip install -U g4f[files]'
)
elif filename.endswith(".docx"):
if has_docx:
return True
elif has_docx2txt:
return True
raise MissingRequirementsError(
f'Install "docx" requirements | pip install -U g4f[files]'
)
elif has_odfpy and filename.endswith(".odt"):
return True
elif has_ebooklib and filename.endswith(".epub"):
return True
elif has_openpyxl and filename.endswith(".xlsx"):
return True
elif filename.endswith(".html"):
if not has_beautifulsoup4:
raise MissingRequirementsError(
f'Install "beautifulsoup4" requirements | pip install -U g4f[files]'
)
return True
elif filename.endswith(".zip"):
return True
elif filename.endswith("package-lock.json") and filename != FILE_LIST:
return False
else:
extension = os.path.splitext(filename)[1][1:]
if extension in PLAIN_FILE_EXTENSIONS:
return True
return False
def spacy_refine_chunks(source_iterator):
if not has_spacy:
raise MissingRequirementsError(
f'Install "spacy" requirements | pip install -U g4f[files]'View on GitHub (pinned to 973504e177)
Solutions
- pip install -U 'g4f[files]'.
- Or pip install beautifulsoup4 directly.
- Verify: python -c 'import bs4'.
- Alternatively pass the extracted plain text of the HTML instead of the .html file.
Example fix
# before
pip install g4f
Attachment('page.html', open('page.html','rb'))
# after
pip install -U 'g4f[files]' Defensive patterns
Strategy: validation
Validate before calling
from g4f.tools.files import supports_filename
supports_filename('page.html') # raises MissingRequirementsError without beautifulsoup4 Type guard
from g4f.errors import MissingRequirementsError
def html_backend_available() -> bool:
try:
import bs4 # noqa
return True
except ImportError:
return False Try / catch
from g4f.errors import MissingRequirementsError
try:
supports_filename('page.html')
except MissingRequirementsError as e:
raise SystemExit('Run: pip install -U g4f[files]') from e Prevention
- Install beautifulsoup4 (or g4f[files]) before accepting .html attachments
- Pre-flight check file types users upload
- Remember .odt/.epub/.xlsx return False silently — handle that case too
- Keep optional deps declared in deployment manifests
When it happens
Trigger: Attaching a .html file in g4f on an install lacking beautifulsoup4 — note the other file types (.odt, .epub, .xlsx) silently return False instead of raising, but .html explicitly raises.
Common situations: Base install without the files extra; environments where bs4 was removed; scripts assuming any text file type is accepted.
Related errors
- Install "pypdf2" requirements | pip install -U g4f[files]
- Install "docx" requirements | pip install -U g4f[files]
- Install "beautifulsoup4" package
- Speech transcription requires installing MarkItdown with the
- Missing CDP requirements
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/e3dcc5c9e4c7d598.
Report an issue: GitHub.