flet icon indicating copy to clipboard operation
flet copied to clipboard

flet publish main.py error

Open mostafa-kessassi opened this issue 1 year ago • 1 comments

Duplicate Check

  • [x] I have searched the opened issues and there are no duplicates

Describe the bug

I use flet publish main.py for build my app and after upload it in Cloudflare And I open console and I see this errors

content script loaded pyodide.asm.js:10 Loading micropip, packaging pyodide.asm.js:10 Loaded micropip, packaging pyodide.asm.js:10 Loading requirements.txt: ['flet', 'deep-translator', 'supabase', 'python-bidi', 'python-docx', 'pushbullet.py', 'arabic-reshaper', 'htmldocx', 'requests', 'num2words', 'pdfkit', 'werkzeug', 'uvicorn'] pyodide.asm.js:10 Uncaught (in promise) PythonError: Traceback (most recent call last): File "/lib/python312.zip/_pyodide/_base.py", line 597, in eval_code_async await CodeRunner( File "/lib/python312.zip/_pyodide/_base.py", line 413, in run_async await coroutine File "<exec>", line 11, in <module> File "/lib/python3.12/site-packages/micropip/package_manager.py", line 133, in install return await install( ^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/micropip/install.py", line 53, in install await transaction.gather_requirements(requirements) File "/lib/python3.12/site-packages/micropip/transaction.py", line 55, in gather_requirements await asyncio.gather(*requirement_promises) File "/lib/python3.12/site-packages/micropip/transaction.py", line 62, in add_requirement return await self.add_requirement_inner(Requirement(req)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/micropip/transaction.py", line 152, in add_requirement_inner await self._add_requirement_from_package_index(req) File "/lib/python3.12/site-packages/micropip/transaction.py", line 214, in addrequirement_from_package_index await self.add_wheel(wheel, req.extras, specifier=str(req.specifier)) File "/lib/python3.12/site-packages/micropip/transaction.py", line 262, in add_wheel await asyncio.gather( File "/lib/python3.12/site-packages/micropip/transaction.py", line 55, in gather_requirements await asyncio.gather(*requirement_promises) File "/lib/python3.12/site-packages/micropip/transaction.py", line 59, in add_requirement return await self.add_requirement_inner(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/micropip/transaction.py", line 152, in add_requirement_inner await self._add_requirement_from_package_index(req) File "/lib/python3.12/site-packages/micropip/transaction.py", line 204, in addrequirement_from_package_index wheel = find_wheel(metadata, req) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.12/site-packages/micropip/transaction.py", line 316, in find_wheel raise ValueError( ValueError: Can't find a pure Python 3 wheel for 'docopt>=0.6.2'.

Code sample

Code
[Paste your code here]

To reproduce

I use Flet==0.28.3 Flet_web=0.28.3 And autre librarys

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

macOS

Operating system details

Windows

Flet version

flet=0.28.3

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

mostafa-kessassi avatar Jul 16 '25 01:07 mostafa-kessassi

Hi @mostafa-kessassi, thanks for the report — this isn't a flet bug, it's a Pyodide/micropip limitation.

What's happening:

  • Your requirements include num2words, which depends on docopt>=0.6.2.
  • docopt on PyPI ships only a source distribution — no wheel.
  • flet publish installs dependencies at runtime via Pyodide's micropip, which can only install pure-Python (or Pyodide-built) wheels. It cannot build sdists in the browser, hence:

    ValueError: Can't find a pure Python 3 wheel for 'docopt>=0.6.2'.

This is noted in the docs — "the package must be a pure Python package or provide a wheel with binaries built for Emscripten."

Options:

  1. Use flet build web instead of flet publish. It resolves deps locally at build time (not in-browser), bundles them into the archive, and supports sdists via the source_packages setting:

    [tool.flet]
    source_packages = ["docopt"]
    

    Both produce a Pyodide-powered SPA, but flet build web sidesteps the micropip sdist limitation and also has faster load time.

  2. Swap num2words for a pure-wheel alternative, or vendor the parts you need.

  3. Prebuild a docopt wheel (pip wheel docopt) and host it, then point requirements.txt at the URL.

Separately — some packages in your list won't run in a Pyodide browser runtime regardless of packaging: uvicorn (ASGI server, needs real sockets), pdfkit (wraps the native wkhtmltopdf binary), and likely parts of supabase. Worth trimming those from the web build.

Let know if you have additional concerns.

ndonkoHenri avatar Apr 17 '26 14:04 ndonkoHenri