我怎么不能让这个.exe与Pyinstaller合作?

发布于 2025-01-22 10:16:13 字数 618 浏览 2 评论 0原文

我正在尝试与Pycharm和Pyinstaller一起玩,因为我对Python非常陌生,并且正在尝试创建一个.exe文件,该文件只是从网站上显示了一大堆育儿HTML,只是为了进行测试。我把它在pycharm中工作了,但是当我以exe的身份运行它时,它只是打开并关闭空白的控制台。我使用:

pyinstaller.exe -onefile -windowed main.py

(main是文件名)。

这是代码:

from bs4 import BeautifulSoup
import requests

Url = "https://www.premierleague.com/players/5178/Mohamed-Salah/stats"
DisplayText = ""

Request = requests.get(Url)
Htmlcode = BeautifulSoup(Request.text, "html.parser")
search = Htmlcode.findAll(text="Goals   ")
narrow = search[0].parent

input(narrow)

我也认为,但是我不确定,Windows安全是否会搞砸了,但我不确定。

I am trying to just play around with Pycharm and Pyinstaller as I am very new to python and am trying to create a .exe file that simply displays a chunk of parented html from a website, just to test. I got it to work within Pycharm but when I run it as an exe, it just opens and closes a blank console. I created the exe using:

pyinstaller.exe --onefile --windowed main.py

(main is the file name).

Here is the code:

from bs4 import BeautifulSoup
import requests

Url = "https://www.premierleague.com/players/5178/Mohamed-Salah/stats"
DisplayText = ""

Request = requests.get(Url)
Htmlcode = BeautifulSoup(Request.text, "html.parser")
search = Htmlcode.findAll(text="Goals   ")
narrow = search[0].parent

input(narrow)

also I think, but I am not sure, windows security may be screwing with this but I am not sure.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏雪无痕 2025-01-29 10:16:13

尝试以pyinstaller而不是pyinstaller.exe运行,除非是错别字检查的最后一行,否则输入(窄)之后(狭窄)将导致错误

编辑:
像没有 - 窗口一样运行

pyinstaller --onefile yourFile.py

,不需要 - 窗口标签,这就是导致错误的原因

Try running as pyinstaller instead of pyinstaller.exe, and unless it's a typo check the last line of code, ''' after the input(narrow) would cause an error

EDIT:
run as

pyinstaller --onefile yourFile.py

without the --windowed, there's no need for the --windowed tag and that's what's causing the error

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文