sublime 安装了Markup 插件,写文档很方便
使用过程中发现导出HTML 文档正常,但是浏览器实时预览不行
打开调试模式:
Ctrl+`打开控制台,查看日志信息,下面是我的日志信息。
OmniMarkupPreviewer: [INFO] Launching web browser for https://127.0.0.1:51004/view/29
UnicodeEncodeError('latin-1', '夏至', 0, 2, 'ordinal not in range(256)')
Traceback (most recent call last):
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1035, in communicate
req.respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 831, in respond
self.server.gateway(self).respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1868, in respond
self.write(chunk)
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1934, in write
self.req.send_headers()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 941, in send_headers
(b"Server", self.server.server_name.encode('ISO-8859-1')))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
UnicodeEncodeError('latin-1', '夏至', 0, 2, 'ordinal not in range(256)')
Traceback (most recent call last):
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1035, in communicate
req.respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 831, in respond
self.server.gateway(self).respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1868, in respond
self.write(chunk)
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1934, in write
self.req.send_headers()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 941, in send_headers
(b"Server", self.server.server_name.encode('ISO-8859-1')))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
UnicodeEncodeError('latin-1', '夏至', 0, 2, 'ordinal not in range(256)')
Traceback (most recent call last):
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1035, in communicate
req.respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 831, in respond
self.server.gateway(self).respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1868, in respond
self.write(chunk)
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1934, in write
self.req.send_headers()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 941, in send_headers
(b"Server", self.server.server_name.encode('ISO-8859-1')))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
UnicodeEncodeError('latin-1', '夏至', 0, 2, 'ordinal not in range(256)')
Traceback (most recent call last):
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1035, in communicate
req.respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 831, in respond
self.server.gateway(self).respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1868, in respond
self.write(chunk)
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1934, in write
self.req.send_headers()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 941, in send_headers
(b"Server", self.server.server_name.encode('ISO-8859-1')))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
UnicodeEncodeError('latin-1', '夏至', 0, 2, 'ordinal not in range(256)')
Traceback (most recent call last):
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1035, in communicate
req.respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 831, in respond
self.server.gateway(self).respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1868, in respond
self.write(chunk)
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1934, in write
self.req.send_headers()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 941, in send_headers
(b"Server", self.server.server_name.encode('ISO-8859-1')))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
UnicodeEncodeError('latin-1', '夏至', 0, 2, 'ordinal not in range(256)')
Traceback (most recent call last):
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1035, in communicate
req.respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 831, in respond
self.server.gateway(self).respond()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1868, in respond
self.write(chunk)
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 1934, in write
self.req.send_headers()
File "C:\Users\xiazhi\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py", line 941, in send_headers
(b"Server", self.server.server_name.encode('ISO-8859-1')))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
python 报错信息显示是因为计算机名是中文导致
解决办法:
1.修改计算机名 使用拉丁字符
- 修改:
C:\Users\XXXX\AppData\Roaming\Sublime Text 3\Packages\OmniMarkupPreviewer\OmniMarkupLib\libs\cherrypy\wsgiserver\wsgiserver3.py
935行到948行之间 编码修改为 UTF-8
if b"date" not in hkeys:
self.outheaders.append(
(b"Date", email.utils.formatdate(usegmt=True).encode('UTF-8')))
if b"server" not in hkeys:
self.outheaders.append(
(b"Server", self.server.server_name.encode('UTF-8')))
buf = [self.server.protocol.encode('ascii') + SPACE + self.status + CRLF]
for k, v in self.outheaders:
buf.append(k + COLON + SPACE + v + CRLF)
buf.append(CRLF)
self.conn.wfile.write(EMPTY.join(buf))
重启sublime
即可正常使用浏览器预览功能