Не подключает модуль pytube, но я его подключил в py-env
error:
JsException(PythonError: Traceback (most recent call last): File "/lib/python3.10/site-packages/_pyodide/_base.py", line 429, in eval_code .run(globals, locals) File "/lib/python3.10/site-packages/_pyodide/_base.py", line 300, in run coroutine = eval(self.code, globals, locals) File "", line 1, in ModuleNotFoundError: No module named 'pytube' )
Код:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>YouTube MP3 Downloader</title>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<py-env>
- pytube
</py-env>
<body>
<button id="but" pys-onClick="downloadyt">Download</button>
<py-script>
from pytube import YouTube
import os
button = int(Element("but"))
def downloadyt():
yt = YouTube("https://www.youtube.com/watch?v=TsHntuufbMs")
video = yt.streams.filter(only_audio=True).first()
out_file = video.download(output_path="C:\\Users\\noteb\\OneDrive\\Робочий стол")
base, ext = os.path.splitext(out_file)
new_file = base + '.mp3'
os.rename(out_file, new_file)
</py-script>
</body>
</html>