Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Python Project Bug #2397

Open
ravishing-rono opened this issue Jul 11, 2024 · 1 comment
Open

🐛 BUG: Python Project Bug #2397

ravishing-rono opened this issue Jul 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ravishing-rono
Copy link

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:

  • python worker
  • no changes made in any other section
  • this is the code "import requests
    from io import BytesIO
    from PIL import Image
    from flask import Flask, request, send_file

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

  • showing error when deploying

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@ravishing-rono ravishing-rono added the bug Something isn't working label Jul 11, 2024
@petebacondarwin petebacondarwin transferred this issue from cloudflare/workers-sdk Jul 15, 2024
@dom96
Copy link
Collaborator

dom96 commented Jul 15, 2024

ModuleNotFoundError: No module named 'requests'

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants