6π
I was having the same issue, and I found the solution. From what I searched it also happens with
Windows 7 & 8.
If you want to know with more detail how I solved it check
the ticket I filed in Djangoβs forums: Error in manage.py runserver on Windows (7 / 8 / 8.1).
Now to solve the error open this file C:\Program Files\Python\lib\site-packages\django\utils\autoreload.py (Iβm using your code as reference) and add
this line of code just before your error (line 279):
new_environ['PATH'] = os.path.abspath(new_environ['PATH'].replace('\u202a', ''))
Your function now should look like this:
def restart_with_reloader():
while True:
args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
if sys.platform == "win32":
args = ['"%s"' % arg for arg in args]
new_environ = os.environ.copy()
new_environ["RUN_MAIN"] = 'true'
new_environ['PATH'] = os.path.abspath(new_environ['PATH'].replace('\u202a', ''))
exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
if exit_code != 3:
return exit_code
Now try using again manage.py runserver. I hope this solves your problem and
donβt feel youβre alone.
3π
In my case it had nothing to do with PATH
, there seem to be CHROME_RESTART
environment setting with some non-english characters. Poping it from new_environ
did the trick:
def restart_with_reloader():
while True:
args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
if sys.platform == "win32":
args = ['"%s"' % arg for arg in args]
new_environ = os.environ.copy()
new_environ["RUN_MAIN"] = 'true'
# This will prevent UnicodeEncodeError
new_environ.pop("CHROME_RESTART", None)
exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
if exit_code != 3:
return exit_code
- [Django]-How to use python-social-auth with google only?
- [Django]-Dynamic plotting using Django and matplotlib
- [Django]-Using Django RelatedField for custom join queries?
- [Django]-Social media link in Django
2π
I tried this
new_environ['PATH'] = os.path.abspath(new_environ['PATH'].replace('\u202a', ''))
but it did not work.
And my solution is
new_environ['PATH'] = os.path.abspath(new_environ['PATH'].encode('ascii', 'replace'))
Hope it will help you!
1π
UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1:invalid character
I had the same problem on windows 7 with
$ python manage.py runserver
Just in case if someone has cyrillic computer name like I had, itβs exactly the thing causing your encoding problem. So the solution is to rename your computer using latin alphabet symbols only.
1π
I had the same problem.
The reason was non latin characters in an environment variables entry.
In my case it was cyrilic name of some folder, while my windows was originally english version.
So it had a conflict. After removing it β everything worked ok.
- [Django]-Edit the opposite side of a many to many relationship with django generic form
- [Django]-User permissions for Django module