1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How can I call my Python function in my javaScript file?

Discussão em 'Python' iniciado por Stack, Setembro 10, 2024.

  1. Stack

    Stack Membro Participativo

    I want to use my Python function in JavaScript. Obviously, my code is more complicated than demonstrated below, but this is the smallest base on which I was able to replicate the problem:

    main.mjs

    dbutils.notebook.run("./aPythonFile.py", 5, {"parameter1": "helloWorld"})


    aPythonFile.py:

    def my_python_function(parameter1):
    print(parameter1)


    Error message:


    ReferenceError: dbutils is not defined at file:///c:/Users/q612386/Dev/SkillUp/SUPAC23-53/Python%20+%20JavaScript%20(ohne%20Listener%20oder%20API)/scripts/tempCodeRunnerFile.js:1:1 at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

    Changing .mjs to .js did not fix the problem.

    I am sure it is just a weird import error but I can't seem to find it. Any other simple solution to call a python function in JavaScript is very welcome, too (except for Flask or django).

    Thank you!

    Continue reading...

Compartilhe esta Página