我正在尝试在 git-bash 上的 Windows python virtualenv 中运行交互式 shell,但它没有运行。奇怪的是,它似乎什么也没做,只是光标在下一行闪烁,没有输出。
$ python manage.py shell
|
但是,我能够运行诸如 migrate、makemigrations、sqlmigrate 之类的命令。命令出现问题 - shell、dbshell、runserver。
这似乎是一些与 git-bash 相关的问题,因为我能够从命令行运行 shell。我正在使用 PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z.exe
在 window 上。
最佳答案
问题是 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
关于python manage.py runserver、shell、dbshell 在 git-bash 上卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31029068/