【问题标题】:Git bash "Watching for file changes with StatReloader" stuck and never loadsGit bash“使用StatReloader监视文件更改”卡住并且永远不会加载
【发布时间】:2021-09-01 05:13:26
【问题描述】:

我已经在我的 PC 上的虚拟环境中设置了一个 Django 项目。使用命令时

python manage.py runserver 0.0.0.0:8000

Bit Bash 停止执行任何操作,我必须结束程序才能重新开始。我等了几分钟,当我结束会话时,一个对话说:

Processes are running in session:
WPID  PID    COMMAND
14904 1534 c:\Users\mine\AppData\Loca
Close anyway?

我已经查看了与此相关的所有问题并尝试了所有解决方案,但无论在虚拟环境中还是在虚拟环境中,我都无法让它工作。

不确定这是否适用,但我也注意到在我的任务管理器中,python3.9.exe 在尝试启动服务器时出现了两次。状态显示正在运行,PID 是不同的数字。

【问题讨论】:

  • 如果你在终端输入 python -V 会发生什么?
  • 您可以尝试运行python manage.py testpython manage.py check 以查看代码是否存在问题(长/无限运行循环等)

标签: python django terminal


【解决方案1】:

这是因为端口 8000 上已经运行了一些东西。您可以通过托管在另一个端口上来运行 Django 服务器,例如8080,但是,您也可以终止该端口上已经运行的任务。关注link,了解如何准确地杀死任何正在运行的进程。

【讨论】:

  • 谢谢,但更改端口也是如此。没有解决问题。
  • 你点击链接了吗?杀死已经运行的端口。
【解决方案2】:

很可能另一个应用程序正在使用端口 8000 运行。尝试使用另一个端口(例如 8088)运行服务器,如果同样的问题仍然存在,请共享。

【讨论】:

  • 问题作者已经评论说问题不是由另一个应用程序使用8000端口引起的。
  • 请在您的回答中提供更多详细信息。正如目前所写的那样,很难理解您的解决方案。
【解决方案3】:

要在特定端口上运行,杀死所有在 Git bash 上显示的 pid (ps -ef)... 使用 (kill -9 pid_no)... 杀死它们... 然后运行 ​​runserver 命令。

例如:

ps -ef
kill -9 123

【讨论】:

    【解决方案4】:

    我最终花钱请人来解决这个问题。这是我与发现问题的人的对话。希望这可以帮助那里的人。

    另外,我注意到有时它仍然会冻结在 watching for file changes with StateReloader 上,直到我打开浏览器并输入 http://localhost:8000/。一旦我这样做了,其余的文本就会加载,我的浏览器会显示The install worked successfully! Congratulations!

    it works, what did you do?
    - We have existing processes on port 8000.I think, you had the server running and kept trying over and over. So, I killed process using 8000 port.
    - Next, I run Django project again.
    - So, now it's working well.
    
    ok. Can you tell me what you did at the start to make it work? Or was it always working?
    - I started git bash session again when I started. Maybe git bash session had problems.
    But this was going on for a day, I restarted the computer several times and restarted git bash. Same issue.
    You must have done something.
    - Sorry, I didn't do anything except restart git bash
    how did you restart it?
    - right click top of window, select NEW
    
    How do I turn server off?
    - press Ctrl + C
    
    - And you didn't quit the server exactly before. Maybe you closed git bash directly and server was still live
    - So, we had many 8000 ports.
    
    Ok. How can I see what is on that port now?
    - You can use this cli
    - netstat -ano | findstr :<PORT>
    
    - We don't have running 8000 port now.
    

    【讨论】:

      【解决方案5】:

      即使使用终止端口、更改端口等,我也从未找到解决此问题的方法。

      它从不显示以下部分:

      Starting development server at http://127.0.0.1:8000/
      

      但是,当我使用 Git Bash 终端包含到 vscode 中时,它会显示 url。

      终端 > 新终端 > 然后:

      结果:

      【讨论】:

        【解决方案6】:

        python manage.py runserver 127.0.0.1:8080

        【讨论】:

        • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-04-14
        • 2019-03-02
        • 1970-01-01
        • 2020-01-03
        • 2021-08-31
        • 1970-01-01
        • 2021-08-05
        相关资源
        最近更新 更多