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

Roh*_*ain 9 python windows django git-bash

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

$ python manage.py shell
|
Run Code Online (Sandbox Code Playgroud)

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

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

小智 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不能在git bash的命令行中工作


Pet*_*ain 3

总结评论中的调查...

研究此类问题的一个好方法是使用pystuck

在这种情况下,这似乎是对 IPython 的某种内部依赖,因为安装 pystuck 也会安装 IPython,并且安装两者后该错误不再重现。