4

So I've been following this django tutorial, and I've been running into some issues with the manage.py commands when using a git bash terminal. I'm using Python 2.7.11 (Anaconda 2.4.1), Django 1.9.5 and git 2.8.1.windows.1 on Windows 10.

Specifically the python manage.py runserver and the python manage.py shell commands don't appear to work properly using a git bash terminal, but they do work when using an Anaconda terminal. I'd like to find a way to get it working with git bash.

According to the tutorial, I should see this output on terminal when running python manage.py runserver:

Performing system checks...

System check identified no issues (0 silenced).

April 19, 2016 - 15:50:53
Django version 1.9, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Using git bash, I know that SOMETHING is working because I can navigate to http://127.0.0.1:8000/ in my browser. I just don't see any output on the terminal.

I continued along with the tutorial, because this didn't really affect anything. It appears to work, just no terminal output. Then I got to this part of the tutorial, where you open a shell with python manage.py shell.

Using git bash, nothing happens. The shell prompt never opens, as if it's stuck. No errors, just a blinking cursor on a new line without a command prompt. If I do the same thing using the Anaconda terminal, the shell opens fine.

At first I thought it was an installation error. So, I attempted to install django using both pip install and conda install, but I still get the same problems. I'm not really sure what's going on here, and I haven't managed to find a solution yet.

Any help is greatly appreciated.

Update:

I found a similar question that doesn't quite have a solution, but it recommends using pystuck to debug. I read the pystuck docs but don't quite understand how to use it for this problem in particular.

Community
  • 1
  • 1
mark s.
  • 656
  • 2
  • 7
  • 14
  • 1
    I just found what may be considered a [duplicate question](http://stackoverflow.com/questions/31029068/python-manage-py-runserver-shell-dbshell-freezes-on-git-bash?rq=1). I spent quite a bit of time looking for similar questions that have already been asked, but didn't see this until after I decided to post this question. I'm in the process of checking if this other question fixes the problems I'm seeing. Will update soon. – mark s. Apr 20 '16 at 16:27
  • There is an SO `git-bash` tag, maybe helpful to finding an answer. – C14L Apr 20 '16 at 16:28
  • @C14L -- Thank you. Updated the tags. – mark s. Apr 20 '16 at 16:31

2 Answers2

2

I have this problem too, when running python manage.py runserver the verbose output is missing, only high level page responses are present. I was using powershell or Git Cmd, that is an option... This fix also resolves issues with using Git Bash to python manage.py makemigrations and python manage.py migrate,

Option: Use Git Cmd or powershell.

Temp Fix: Run this command in Git Bash to generate verbose output for this working session: alias python='winpty python.exe'

Perm Fix: Use the temp fix in a .bashrc file, git bash will always have verbose output.

 cd ~      #Takes you to your root directory.
 touch .bashrc

Edit the file using VIM, or editor of your choice, add the following line (note: Notepad from MS Windows will not save this file correctly. Do not use notepad.):

 alias python='winpty python.exe'

Restart Git Bash.

Note: In some circumstances, you will get one prompt when you launch git bash:

"WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.

This looks like an incorrect setup. A ~/.bash_profile that loads ~/.bashrc will be created for you."

You will notice a second file .bash_profile was created for you and you are good to go!

That's it... enjoy.

Andonon
  • 21
  • 6
1

I don't know why but I found a bit of a workaround. When running python manage.py runserver in the Git Bash window on windows 7 (using Anaconda2) I also DID NOT get the expected:

Performing system checks...
System check identified no issues (0 silenced).

February 09, 2017 - 17:39:48
Django version 1.10.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8090/
Quit the server with CTRL-BREAK.

Doing the same in the native windows CMD prompt worked!!!

I had manage.py open in Sublime Text and when I saved it (or any other file in the project) the server (started and currently frozen in the git bash window) started up as expected.

Maybe this will work for you. Don't know why it does or should...

DrJMcAuliffe
  • 348
  • 4
  • 15