python manage.py runserver,shell,dbshel​​l在git-bash上冻结

时间:2015-06-24 14:15:54

标签: python django windows git-bash

我试图在windows中的python virtualenv中运行交互式shell,在git-bash上,但它没有运行。奇怪的是,它似乎没有做任何事情,只是光标在下一行闪烁,没有输出。

$ python manage.py shell
|

但是,我能够运行诸如 - migrate,makemigrations,sqlmigrate之类的命令。命令发生问题 - shell,dbshel​​l,runserver。

这似乎是一些与git-bash相关的问题,因为我能够从命令行运行shell。我在Windows上使用PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z.exe

3 个答案:

答案 0 :(得分:9)

问题是python.exe本身与gitbash有问题。据说,它与ncurses库有关。

解决方案是键入“winpty python.exe”而不是python。 “winpty python.exe manage.py shell”应该可以正常工作。您还可以创建别名以绕过该问题。键入“alias python ='winpty python.exe'”将使“python manage.py shell”正常工作。

这个答案更好地解释了: Python not working in the command line of git bash

答案 1 :(得分:3)

总结评论中的调查......

调查这些问题的一个好方法是使用pystuck

在这种情况下,它似乎是对IPython的某种内部依赖,因为安装pystuck也会安装IPython,并且不再使用Both安装错误。

答案 2 :(得分:0)

我不知道命令shelldbshell,但对于runserver命令,我遇到了同样的问题。我解决了运行

python manage.py runserver --noreload

转到http://127.0.0.1:8000/并刷新浏览器。您的终端必须显示您网站的信息