Python Import Error

Can anyone help with this error? It's a simple script for testing. This script works locally on my pc as well. Source code:
import logging
from loguru import logger
from logtail import LogtailHandler

logtail = LogtailHandler(source_token='')

def main():
logger.remove()
logger.add("/var/log/loguru.log")

logger.add(
logtail,
format="{message}",
level="INFO",
backtrace=False,
diagnose=False,
)

logger.trace("A trace message.")
logger.debug("A debug message.")
logger.info("An info message.")
logger.success("A success message.")
logger.warning("A warning message.")
logger.error("An error message.")
logger.critical("A critical message.")

if __name__ == "__main__":
main()
import logging
from loguru import logger
from logtail import LogtailHandler

logtail = LogtailHandler(source_token='')

def main():
logger.remove()
logger.add("/var/log/loguru.log")

logger.add(
logtail,
format="{message}",
level="INFO",
backtrace=False,
diagnose=False,
)

logger.trace("A trace message.")
logger.debug("A debug message.")
logger.info("An info message.")
logger.success("A success message.")
logger.warning("A warning message.")
logger.error("An error message.")
logger.critical("A critical message.")

if __name__ == "__main__":
main()
Error:
ExecutionErr: ExitCode: 1, last log lines:
call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/tmp/windmill/wk-default-ce4729853c5d-I4gB0/0193ae94-236d-b0ae-29a2-6da341a6fd22/wrapper.py", line 10, in <module>
from u.ashafer import log_testing as inner_script
File "/tmp/windmill/wk-default-ce4729853c5d-I4gB0/0193ae94-236d-b0ae-29a2-6da341a6fd22/u/ashafer/log_testing.py", line 3, in <module>
from logtail import LogtailHandler
ImportError: cannot import name 'LogtailHandler' from 'logtail' (/tmp/windmill/cache/python_311/logtail==1.0.1/logtail/__init__.py)
ExecutionErr: ExitCode: 1, last log lines:
call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/tmp/windmill/wk-default-ce4729853c5d-I4gB0/0193ae94-236d-b0ae-29a2-6da341a6fd22/wrapper.py", line 10, in <module>
from u.ashafer import log_testing as inner_script
File "/tmp/windmill/wk-default-ce4729853c5d-I4gB0/0193ae94-236d-b0ae-29a2-6da341a6fd22/u/ashafer/log_testing.py", line 3, in <module>
from logtail import LogtailHandler
ImportError: cannot import name 'LogtailHandler' from 'logtail' (/tmp/windmill/cache/python_311/logtail==1.0.1/logtail/__init__.py)
2 Replies
SpookyBiscuit40
SpookyBiscuit40OP2w ago
I don't know if there is any other solution but I just found out I can add requirements.txt options to the top of the program. After I added it like this the script ran with no errors.
#requirements:
#logtail-python
#loguru
#requirements:
#logtail-python
#loguru
fooosieee
fooosieee2w ago
you can use extra_requirements for that like this:
# extra_requirements:
# aiodns
# extra_requirements:
# aiodns