Opened 10 years ago
Closed 10 years ago
#23704 closed Bug (invalid)
Error in manage.py runserver on Windows (7 / 8 / 8.1)
Reported by: | 3rdWorldCitizen | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.7 |
Severity: | Normal | Keywords: | Windows runserver |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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:
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":
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:
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 (/).
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', ''))
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.
Thanks for the detailed and colorful report. This doesn't look like a bug in Django to me but rather some issue with your PATH variable. The forward slash you highlighted seems suspicious (why not a backslash there?) but I am not a Windows user. I'd recommend to seek out the assistance of other Windows users via the resources at TicketClosingReasons/UseSupportChannels. If after getting help, someone suggests that this is something Django should address, please reopen the ticket. Thanks!