您现在的位置是:主页 > news > 银川做企业网站/抖音关键词排名系统
银川做企业网站/抖音关键词排名系统
admin2025/5/2 10:54:28【news】
简介银川做企业网站,抖音关键词排名系统,企业咨询方案,做网站用什么语言好最近碰到的Python项目中,需要安装MySQL-python依赖,并且项目使用tornado,以下是记录在其中碰到的坑。0x01 tornado在render渲染html页面时报错访问页面时服务器响应500,查看错误日志,提示:utf8 codec cant …
最近碰到的Python项目中,需要安装MySQL-python依赖,并且项目使用tornado,以下是记录在其中碰到的坑。
0x01 tornado在render渲染html页面时报错
访问页面时服务器响应500,查看错误日志,提示:'utf8' codec can't decode byte 0xbf in position 15:invalid start byte
疑惑了很久文件编码格式等,后来debug跟踪发现错误,是项目路径出现问题,最好不要在包含中文路径中:
snipaste20180809_155405.png
0x02 MySQL-python 1.2.3安装
项目需要使用MySQL-python 1.2.3,然而通过pip安装会一直失败:
snipaste20180809_155857.png
似乎是注册表中找不到某个值
可以通过以下步骤解决:
1、使用要安装的python环境运行此脚本:register.py#!/usr/bin/env python# -*- coding:utf-8 -*-import sysfrom _winreg import *# tweak as necessaryversion = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"pythonkey = "PythonPath"pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
)def RegisterPy():
try:
reg = OpenKey(HKEY_CURRENT_USER, regpath) except EnvironmentError as e: try:
reg = CreateKey(HKEY_CURRENT_USER, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg) except: print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg) print "=== Python", version, "is already registered!"
return
CloseKey(reg) print "*** Unable to register!"
print "*** You probably have another Python installation!"RegisterPy()
snipaste20180809_160020.png
作者:日生三金
链接:https://www.jianshu.com/p/1d14324eb584