1. 程式人生 > >windos下安裝django

windos下安裝django

value func *** .py gic ble 文件 code htm

一:pip install Django

安裝完以後,運行python manager.py runserver 0.0.0.0:8000報錯1):沒有安裝Mysql-python,安裝Mysql-python的時候報錯沒有註冊,把下面的代碼保存為register.py文件,然後執行python register.py,就可以了
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
#
written by Joakim Loew for Secret Labs AB / PythonWare # # source: # http://www.pythonware.com/products/works/articles/regpy20.htm # # modified by Valentine Gogichashvili as described in http:[email protected]/msg10512.html import sys from _winreg import * # tweak as necessary version = 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!" if __name__ == "__main__": RegisterPy()

技術分享 2)字符集不對: 技術分享 解決辦法:在D:\Python27\Lib\mimetypes.py 的import下添加如下代碼
if sys.getdefaultencoding() != gbk: 
    reload(sys) 
    sys.setdefaultencoding(gbk)
3):安裝了Mysql-python但是還是報錯,這是因為安裝的版本錯了,要安裝32位的,MySQL-python-1.2.5.win32-py2.7.exe 這裏的32位不是指你的操作系統32位,而是Python的
技術分享 4):然後運行的時候還報錯: 技術分享 解決辦法,找到D:\Python27\lib\functools.py 這個文件,把第56行的convert這一段替換成下面這一段
convert = {
        __lt__: [(__gt__, lambda self, other: not (self < other or self == other)),
                   (__le__, lambda self, other: self < other or self == other),
                   (__ge__, lambda self, other: not self < other)],
        __le__: [(__ge__, lambda self, other: not self <= other or self == other),
                   (__lt__, lambda self, other: self <= other and not self == other),
                   (__gt__, lambda self, other: not self <= other)],
        __gt__: [(__lt__, lambda self, other: not (self > other or self == other)),
                   (__ge__, lambda self, other: self > other or self == other),
                   (__le__, lambda self, other: not self > other)],
        __ge__ : [(__le__, lambda self, other: (not self >= other) or self == other),
                   (__gt__, lambda self, other: self >= other and not self == other),
                   (__lt__, lambda self, other: not self >= other)]
    }

然後成功啦

windos下安裝django