cloudflare / workerd

The JavaScript / Wasm runtime that powers Cloudflare Workers
https://blog.cloudflare.com/workerd-open-source-workers-runtime/
Apache License 2.0
6.28k stars 308 forks source link

🐛 BUG: Python Project Bug #2397

Open ravishing-rono opened 4 months ago

ravishing-rono commented 4 months ago

Which Cloudflare product(s) does this pertain to?

Workers for Platforms

What version(s) of the tool(s) are you using?

3.63.2 Wrangler

What version of Node are you using?

20.13.1

What operating system and version are you using?

Windows 11

Describe the Bug

Observed behavior

Showing this error "Uncaught Error: PythonError: Traceback (most recent call last): File "/lib/python312.zip/_pyodide/_base.py", line 629, in pyimport_impl res = import(stem, fromlist=fromlist) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/session/metadata/entry.py", line 1, in import requests ModuleNotFoundError: No module named 'requests' at pyodide-internal:generated/pyodide.asm:20:9998 in new_error at wasm://wasm/0265dd42:1:1493017 in $wrap_exception at wasm://wasm/0265dd42:1:1493363 in $pythonexc2js at pyodide-internal:generated/pyodide.asm:20:607956 in Module._pythonexc2js at pyodide-internal:generated/pyodide.asm:20:64098 in Module.callPyObjectKwargs at pyodide-internal:generated/pyodide.asm:20:65055 in Module.callPyObject at pyodide-internal:generated/pyodide.asm:20:79132 in apply at pyodide-internal:generated/pyodide.asm:20:77371 in apply at pyodide-internal:generated/pyodide.asm:20:102862 in pyimport at pyodide:python-entrypoint-helper:31:18 in pyimportMainModule (Code: 10021) "

Expected behavior

Won't show any errors

Steps to reproduce

Please provide the following:

app = Flask(name)

@app.route('/overlay', methods=['GET']) def overlay_image(): base_image_url = request.args.get('base') overlay_image_url = 'https://www.overlayimage.png'

response = requests.get(base_image_url)
base_image = Image.open(BytesIO(response.content))

response = requests.get(overlay_image_url)
overlay_image = Image.open(BytesIO(response.content))

if base_image.mode != 'RGBA':
    base_image = base_image.convert('RGBA')
if overlay_image.mode != 'RGBA':
    overlay_image = overlay_image.convert('RGBA')

overlay_image = overlay_image.resize(base_image.size, Image.ANTIALIAS)

combined_image = Image.alpha_composite(base_image, overlay_image)

image_io = BytesIO()
combined_image.save(image_io, 'PNG')
image_io.seek(0)

return send_file(image_io, mimetype='image/png')

if name == 'main': app.run(host='0.0.0.0', port=8000)" in the entry.py

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

dom96 commented 4 months ago

ModuleNotFoundError: No module named 'requests'

Did you specify requests (and your other imports) in a requirements.txt file?