python2 一些错误处理
python2各种问题
pip安装django出错:python2 -m pip install django
编码问题:Unicode Decode Error ascii codec can't decode byte...
原因:windows系统默认编码是gbk,而pip默认编码是utf8,故出错
解决方法: python27\Lib\site-packages下,新建一个 sitecustomize.py 文件,写入
import sys
sys.setdefaultencoding('gbk')
pip安装django出错:python2 -m pip install django
源码编译问题:IOError: [Errno 22] invalid mode ('wb') or filename
原因:pip默认下载最新版本,最新版本为django2.0,而源上只有django2.0 python3的whl文件,没有python2的whl文件。因此只能采用源码编译安装,而源码编译安装又出了这个错误
解决方法:指定下载较低版本的django,这里用django 1.11.4
查看django版本:https://pypi.python.org/pypi
pip指定版本号用“==”:
python2 -m pip install django==1.11.4
启动django出错:python2 manage.py runserver
RuntimeError: maximum recursion depth exceeded in cmp
django启动时出错,报错显示在python27/Lib/functool.py的第56行
解决办法:在python目录中的Lib下面找到functools将56行
convert = {
'__lt__': [('__gt__', lambda self, other: other < self),
('__le__', lambda self, other: not other < self),
('__ge__', lambda self, other: not self < other)],
'__le__': [('__ge__', lambda self, other: other <= self),
('__lt__', lambda self, other: not other <= self),
('__gt__', lambda self, other: not self <= other)],
'__gt__': [('__lt__', lambda self, other: other > self),
('__ge__', lambda self, other: not other > self),
('__le__', lambda self, other: not self > other)],
'__ge__': [('__le__', lambda self, other: other >= self),
('__gt__', lambda self, other: not other >= self),
('__lt__', lambda self, other: not self >= other)]
}
修改成:
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连接postgresql出错:python2 manage.py runserver
django.db.utils.OperationalError:
FATAL: no pg_hba.conf entry for host "172.16.23.129", user "postgres", database "datamanager", SSL on
FATAL: no pg_hba.conf entry for host "172.16.23.129", user "postgres", database "datamanager", SSL off
PostgreSQ数据库为了安全,它不会监听除本地以外的所有连接请求,当用户通过JDBC访问是,会报一些如下的异常:
org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host
要解决这个问题,只需要在PostgreSQL数据库的安装目录下找到/data/pg_hba.conf,找到“# IPv4 local connections:”
在其下加上请求连接的机器IP
host all all 127.0.0.1/32 md5
32是子网掩码的网段;md5是密码验证方法,可以改(见文件pg_hba.conf上的说明)
最新文章
- 第3章 Linux常用命令(4)_帮助、用户管理和解压缩命令
- myBatis oracle 与mysql自增问题
- WPF ListView 排序
- 【转】C#环形队列
- Apache 配置HTTPS协议搭载SSL配置
- SQLSERVER DBA容易犯的十个错误
- Go Mobile 例子 audio 源码分析
- Linux下查看文件和文件夹大小的df和du命令
- listView中的button控件获取item的索引
- Hug the princess(思维,位运算)
- 【Unity】Unity中C#与Android中Java的互相调用遇到的一些问题
- 基于QTcpSocket和QTcpServer的Tcp通讯以及QDataStream序列化数据
- WPF: 本地化(Localization) 实现
- linux服务器添加一块新硬盘不用重新启动机器的操作
- Oracle中rownum和rowid的理解
- 【文件】使用word的xml模板生成.doc文件
- python中安装Tensorflow
- 【codeforces】【比赛题解】#851 CF Round #432 (Div.2)
- Android网络:开发浏览器(二)——功能完善之书签功能
- SVNserver搭建
热门文章
- 2.请求库之requests
- 逻辑漏洞-客户端验证的邮箱-Web渗透实例之中国教育部青少年普法网站逻辑漏洞
- 【Unity】Unity中资源动态载入的两种方式之AssetsBundle
- php-fpm nginx 使用 curl 请求 https 出现 502 错误
- Installing scipy on redhat with error “no lapack/blas resources found”
- Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof)
- Tutorial : How to Create a Border Glow Effect in JavaFX
- 使用BestSync同步软件与坚果云同步
- String.Join
- Windows编程中回调函数的使用心得(MFC篇)