zoukankan      html  css  js  c++  java
  • windos下安装django

    一: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://www.mail-archive.com/distutils-sig@python.org/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:Python27Libmimetypes.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:Python27libfunctools.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)]
        }
    然后成功啦
     
     
     
  • 相关阅读:
    验证码处理 -- 爬虫
    Django知识点总结
    关于sql去重
    tsxt-01
    崔老师爬取top100的源码(会403)
    简单爬取网页源码
    爬取猫眼top100
    python-自动发邮件
    python-装饰器
    Python 爬虫基础Selenium库的使用
  • 原文地址:https://www.cnblogs.com/lemon-le/p/6890957.html
Copyright © 2011-2022 走看看