
Folder structure:
TypeScript
youtube
- requirements.txt
- src/
| main.py
| transcribe.py
main.py:
TypeScript
from transcribe import transcribe_video
def main():
youtube_url = context.req.body
if youtube_url:
return context.res.json(transcribe_video(youtube_url))
else:
raise ValueError('youtubeUrl is missing or empty')
Runs locally. When deployed to cloud I get the error:
TypeScript
Traceback (most recent call last):
File "/usr/local/server/src/server.py", line 165, in handler
output = await asyncio.wait_for(execute(context), timeout=safeTimeout)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
return fut.result()
File "/usr/local/server/src/server.py", line 150, in execute
userModule = importlib.import_module("function." + userPath)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/server/src/function/main.py", line 1, in <module>
from transcribe import transcribe_video
ModuleNotFoundError: No module named 'transcribe'
I'm assuming this is a Docker path issue but I haven't been able to figure out the right way to import my custom transcribe.py
module.
TL;DR
Issue: ModuleNotFoundError for 'transcribe' when the python project is deployed to the cloud due to incorrect module import path.
Solution: Update the import statement in `main.py` to correctly import the `transcribe.py` module:
Change: `from transcribe import transcribe_video`
To: `from src.transcribe import transcribe_video`
This modification should resolve the module import error.
Entry point is src/main.py
Root dir is functions/youtube/
Recommended threads
- Appwrite Cloud + Firebase hosting login ...
Hey team, can you please add the following to the CORS allowlist for my cloud project? Project ID: 68633b67002faf66fbcf Domains to allow: - https://taggit-...
- Collection Permission issue
I am facing issue in my Pro account. "Add" button is disabled while adding permission in DB collection settings.
- Opened my website after long time and Ba...
I built a website around a year back and and used appwrite for making the backend. At that time the website was working fine but now when i open it the images a...
