.exe 文件在我尝试 运行 时出错

.exe file gives error when I try to run it

我有一个 python-flask 刽子手游戏,我尝试使用 pyinstaller 和以下命令行将其包装到一个可执行文件中:

pyinstaller -w -F --add-data "templates:templates" --add-data "static:static" hangman.py

它似乎工作正常,并创建了 build、dist 以及 .spec 文件但是,当我尝试 运行 可执行文件时,我收到以下错误:

flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
 * Serving Flask app "hangman" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Traceback (most recent call last):
  File "hangman.py", line 101, in <module>
  File "flask/app.py", line 990, in run
  File "werkzeug/serving.py", line 1012, in run_simple
  File "werkzeug/serving.py", line 956, in inner
  File "werkzeug/serving.py", line 807, in make_server
  File "werkzeug/serving.py", line 701, in __init__
  File "socketserver.py", line 452, in __init__
  File "http/server.py", line 138, in server_bind
  File "socketserver.py", line 466, in server_bind
OSError: [Errno 98] Address already in use
[46425] Failed to execute script 'hangman' due to unhandled exception!

我对编程比较陌生,所以请不要介意任何技术术语的错误使用。

尝试像这样关闭重新加载器:

app.run(debug=True, use_reloader=False)

[编辑] 似乎其他一些应用程序正在使用相同的端口。通过

查看
netstat -tulpn

要获取更多信息,您还可以使用:

tasklist

当您获得 pid 时,我建议您手动停止它

你也可以通过命令 kill 来杀死它:

Taskkill /PID THE_PORT /F