python manage.py runserver, shell, dbshell freezes on git-bash

帅比萌擦擦* 提交于 2019-11-29 18:52:59

问题


I'm trying to run the interactive shell in python virtualenv in windows, on git-bash, but it isn't running. Strange thing is, it doesn't seem to do anything, just the cursor is blinking on the next line, giving no output.

$ python manage.py shell
|

However, I'm able to run commands like - migrate, makemigrations, sqlmigrate. Problem is occurring with the commands - shell, dbshell, runserver.

This seems to be some git-bash related issue, because I'm able to run shell from command line. I'm using PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z.exe on windows.


回答1:


Summarising the investigation in the comments...

A good way to investigate these sorts of problems is to use pystuck.

In this case, it would appear to have been some sort of internal dependency on IPython as installing pystuck also installs IPython and the bug no longer reproduces with Both installed.




回答2:


The problem is python.exe itself has issues with gitbash. Supposedly, it has something to do with the ncurses library.

The solution is to type "winpty python.exe" instead of python. "winpty python.exe manage.py shell" should work. You can also create an alias to bypass the issue. Typing "alias python='winpty python.exe'" will make it so "python manage.py shell" works as it should.

This answer explains it better: Python not working in the command line of git bash




回答3:


I don't have idea for the commands shell, and dbshell, but for runservercommand, I had same issue. I solved running

python manage.py runserver --noreload

Go to http://127.0.0.1:8000/ and refresh the browser. Your terminal must show the info of your website



来源:https://stackoverflow.com/questions/31029068/python-manage-py-runserver-shell-dbshell-freezes-on-git-bash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!