Error in manage.py runserver with Django on windows 8.1

后端 未结 5 2001
盖世英雄少女心
盖世英雄少女心 2021-01-14 19:11

I couldn\'t find this exitcode anywhere but hopefully one of you could help me or let me know if this is a bug in python/Django.

Anyway, first here\'s the stacktrace

5条回答
  •  一个人的身影
    2021-01-14 19:39

    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.

提交回复
热议问题