#23704: Error in manage.py runserver on Windows (7 / 8 / 8.1)
---------------------------------+-------------------------------
     Reporter:  3rdWorldCitizen  |      Owner:  nobody
         Type:  Bug              |     Status:  new
    Component:  Uncategorized    |    Version:  1.7
     Severity:  Normal           |   Keywords:  Windows runserver
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  0                |      UI/UX:  0
---------------------------------+-------------------------------
 I've added the 3 versions mentioned in the summary because
 while searching for a solution to this bug I've found that
 it occurred in those ones also.


 == Technical Specs ==

 System: Windows 8.1
 Python: 3.4
 Django: 1.7
 Virtual Enviroment: 2.7


 == Explanation of the bug ==

 After creating my project with "manage.py startproject"
 I tried to check if it was created correctly by running
 the local server.

 When I tried to do so with "manage.py runserver" a command
 feedback appeared reporting the next error:

 [[Image(http://s21.postimg.org/e362aaql3/traceback_error.png)]]

 In line 279, the code indicated that it was a problem with
 the encoding of a character. For what I know 'mbcs' codec is
 only used with Windows machines. I tried all suggestions
 in StackOverflow and the likes with no improvement.

 Then I started digging in the code and I found the file
 with the error "autoreload.py":

 [[Image(http://s21.postimg.org/5v44payon/autoreload_before.png)]]

 The problem occurred with the method "os.spawnve" that
 executes the program path in a new process. The real
 usage is beyond my knowledge.

 I decided to look up the arguments that were given to
 this function and printed each one of them to see
 what was happening.

 The arguments "sys.executable" & "args" didn't present
 any errors. It was a clean print. "new_environ", that's
 another story. It presented a new error indicating
 that a Unicode value (\u202a) couldn't be decoded
 by the function charmap.

 I searched this particular Unicode and it's used for
 indicating '''directional embedding''' (more of this at:
 [http://unicode.org/reports/tr9/#Directional_Formatting_Codes]).

 It appears that this particular Unicode character isn't supported
 in Windows, that includes the 3 versions indicated in the summary.
 It so strange to Windows environment that even if you try to search
 the code in a browser it can't recognized it:

 [[Image(http://s21.postimg.org/ucw8d7193/path_key.png)]]

 After that I tried to print each key with it respective value to
 see which of them had the Unicode character. The winner was the
 key 'PATH' that stores the Path used by Windows to let the
 command prompt or PowerShell execute any command that appears
 in the path. This particular path has this character but can't
 be seen. If I tried to remove this character, the first chunk
 of the path that indicates the environment of the Django project
 presented an error in it's path. An terrible front-slash (/).

 [[Image(http://s21.postimg.org/wdmry0xef/unicode_error.png)]]


 == Personal Solution ==

 I eliminated the Unicode character and modified the PATH value
 so that all paths have the Windows structure. I just added
 a single line of code before line 279:


 {{{
 new_environ['PATH'] =
 os.path.abspath(new_environ['PATH'].replace('\u202a', ''))
 }}}

 [[Image(http://s21.postimg.org/dzc8u1l3r/autoreload_after.png)]]

 Although this code allows to run the server without issue I still
 want to know if this workaround won't affect Django performance or
 usage in the future.

 I hope someone can help me because being a newbie and Windows lack
 of support is driving me nuts. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/23704>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/058.3a0583c435770b7b6250123f0d387872%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to