Eel python:Javascript错误Eel不是函数

Eel python:Javascript错误Eel不是函数,javascript,python,html,eel,Javascript,Python,Html,Eel,我正在使用eel与python进行通信。我在目录C:\Users\Desktop\Eel中工作,其中我有app.py,在UI文件夹中我有index.html、myjava.js、style.css和图像,但没有一个叫做Eel.js。我这么说是因为在文档中,它说要包含名为/eel.js的脚本 index.html app.py 当我运行py文件时,index.html加载,然后当我单击div时,我进入函数,但它抛出错误: myjava.js:2 Uncaught TypeError: eel.ru

我正在使用eel与python进行通信。我在目录C:\Users\Desktop\Eel中工作,其中我有app.py,在UI文件夹中我有index.html、myjava.js、style.css和图像,但没有一个叫做Eel.js。我这么说是因为在文档中,它说要包含名为/eel.js的脚本

index.html

app.py

当我运行py文件时,index.html加载,然后当我单击div时,我进入函数,但它抛出错误:

myjava.js:2 Uncaught TypeError: eel.runpy is not a function

我遗漏了什么?

似乎init语句是先写的。 在导入语句之后写@eel.expose语句怎么样

我不擅长英语,所以我担心这会有意义。 但如果我能帮忙,我会很高兴的。

试试这个:

import eel

eel.init('UI')
eel.start('index.html', size=(900, 550))

@eel.expose()
def runpy():
     ....code which creates an excel file in desktop...
我改变了什么?
我添加到@eel.expose

在我的例子中,我必须在通过decorator公开函数后启动eel:

import eel

eel.init('UI')

@eel.expose
def runpy():
     ....code which creates an excel file in desktop...

eel.start('index.html', size=(900, 550))

在从中删除/eel.js之前,我也遇到了同样的问题

<script type="text/javascript" src="/eel.js"></script>
现在看起来像

<script type="text/javascript" src="eel.js"></script>

过去我把鳗鱼脚本标签放在身体的末端,而不是头部,也许是代替鳗鱼。runpy,只是runpy,但我真的不知道。你的eel脚本在你启动后是否继续运行?它是一个句子,而不是一个语句。
import eel

eel.init('UI')
eel.start('index.html', size=(900, 550))

@eel.expose()
def runpy():
     ....code which creates an excel file in desktop...
import eel

eel.init('UI')

@eel.expose
def runpy():
     ....code which creates an excel file in desktop...

eel.start('index.html', size=(900, 550))
<script type="text/javascript" src="/eel.js"></script>
<script type="text/javascript" src="eel.js"></script>