Python 运行Django应用程序时出错
当我在pycharm或cmd中运行django项目时,我得到了这个错误。我该怎么办 “C:\ProgramFiles(x86)\JetBrains\PyCharm 3.4.1\bin\runnerw.exe”C:\Python34\python.exe C:/Users/admin/PycharmProjects/untitled/manage.py runserver 8000 正在验证模型Python 运行Django应用程序时出错,python,django,python-3.x,django-forms,Python,Django,Python 3.x,Django Forms,当我在pycharm或cmd中运行django项目时,我得到了这个错误。我该怎么办 “C:\ProgramFiles(x86)\JetBrains\PyCharm 3.4.1\bin\runnerw.exe”C:\Python34\python.exe C:/Users/admin/PycharmProjects/untitled/manage.py runserver 8000 正在验证模型 0 errors found August 15, 2014 - 13:58:27 Django ve
0 errors found
August 15, 2014 - 13:58:27
Django version 1.6.5, using settings 'untitled.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x022A32B8>
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\django\utils\autoreload.py", line 93, in wrapper
fn(*args, **kwargs)
File "C:\Python34\lib\site-packages\django\core\management\commands\runserver.py", line 127, in inner_run
ipv6=self.use_ipv6, threading=threading)
File "C:\Python34\lib\site-packages\django\core\servers\basehttp.py", line 167, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "C:\Python34\lib\site-packages\django\core\servers\basehttp.py", line 109, in __init__
super(WSGIServer, self).__init__(*args, **kwargs)
File "C:\Python34\lib\socketserver.py", line 429, in __init__
self.server_bind()
File "C:\Python34\lib\site-packages\django\core\servers\basehttp.py", line 113, in server_bind
super(WSGIServer, self).server_bind()
File "C:\Python34\lib\wsgiref\simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "C:\Python34\lib\http\server.py", line 135, in server_bind
self.server_name = socket.getfqdn(host)
File "C:\Python34\lib\socket.py", line 460, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 6: invalid continuation byte
发现0个错误
2014年8月15日-13:58:27
Django版本1.6.5,使用设置“untitled.settings”
正在启动开发服务器http://127.0.0.1:8000/
使用CTRL-BREAK退出服务器。
由启动的线程中存在未处理的异常
回溯(最近一次呼叫最后一次):
文件“C:\Python34\lib\site packages\django\utils\autoreload.py”,第93行,在包装器中
fn(*args,**kwargs)
文件“C:\Python34\lib\site packages\django\core\management\commands\runserver.py”,第127行,在内部运行
ipv6=self.use_ipv6,线程=线程)
文件“C:\Python34\lib\site packages\django\core\servers\basehttp.py”,第167行,正在运行
httpd=httpd\u cls(服务器地址,WSGIRequestHandler,ipv6=ipv6)
文件“C:\Python34\lib\site packages\django\core\servers\basehttp.py”,第109行,在\uuu init中__
超级(WSGIServer,self)。\uuuuuu初始化(*args,**kwargs)
文件“C:\Python34\lib\socketserver.py”,第429行,在_init中__
self.server_bind()
文件“C:\Python34\lib\site packages\django\core\servers\basehttp.py”,第113行,服务器绑定
super(WSGIServer,self).server_bind()
服务器绑定中的第50行文件“C:\Python34\lib\wsgiref\simple\u server.py”
HTTPServer.server\u绑定(self)
服务器绑定中第135行的文件“C:\Python34\lib\http\server.py”
self.server_name=socket.getfqdn(主机)
getfqdn中第460行的文件“C:\Python34\lib\socket.py”
主机名、别名、IPADRS=gethostbyaddr(名称)
UnicodeDecodeError:“utf-8”编解码器无法解码位置6中的字节0xcf:无效的连续字节
1)检查设置.py manage.py wsgi.py等中的非ascii文本
2) 找到时添加
# -*- coding: utf-8 -*-
在文件的开头
3) 并在包含非ascii文本的字符串的末尾添加u
例如:u“这个字符不是unicode:uşiğğ”
///对于Python2.x我没有测试它,但我认为这是一个python错误。您提供的堆栈跟踪表明,当主机名被复制到python unicode字符串中时,UnicodeDecodeError将被触发 请检查您正在使用的计算机的主机名是否包含unicode字符
似乎和你的问题一样。在文章中,python被引用,它仍然处于打开状态。尝试验证主机名。您的主机名可能包含一些非ascii文本。
似乎您使用的是Windows 7操作系统。对不起,不是:请看一下没有非ascii字符。我刚刚安装了Python 3.x,没有做任何更改?我错过了。这对我来说有点像,但这应该解决。。。主机名是否包含unicode字符?