为什么import wx 出错pg会出错

为什么会出错,我已经安装了django了_百度知道
为什么会出错,我已经安装了django了
in &__init__;http&#92,module&&site-packages&#92:
from django:\lib\PYTHON&#92.py&NuoV&#92.http import HttpResponse
File &;;django\pyshell#9&gt, line 1D, line 336
except IOError:
^SyntaxError.http import HttpResponseTraceback (most recent call last);&quot
提问者采纳
请使用python2来运行django,django目前还不支持python3.
来自团队:
其他类似问题
为您推荐:
django的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁大家来帮忙看下:为什么from imp import reload之后用reload(文件名)会出错?
[问题点数:100分,结帖人u]
大家来帮忙看下:为什么from imp import reload之后用reload(文件名)会出错?
[问题点数:100分,结帖人u]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2014年8月 其他开发语言大版内专家分月排行榜第二2014年7月 其他开发语言大版内专家分月排行榜第二2014年5月 其他开发语言大版内专家分月排行榜第二2014年4月 其他开发语言大版内专家分月排行榜第二2014年3月 其他开发语言大版内专家分月排行榜第二2014年1月 其他开发语言大版内专家分月排行榜第二2013年12月 其他开发语言大版内专家分月排行榜第二2013年11月 其他开发语言大版内专家分月排行榜第二2013年3月 其他开发语言大版内专家分月排行榜第二2012年5月 其他开发语言大版内专家分月排行榜第二2012年4月 其他开发语言大版内专家分月排行榜第二2010年10月 其他开发语言大版内专家分月排行榜第二2010年9月 其他开发语言大版内专家分月排行榜第二
2013年9月 其他开发语言大版内专家分月排行榜第三2012年6月 其他开发语言大版内专家分月排行榜第三
2014年8月 其他开发语言大版内专家分月排行榜第二2014年7月 其他开发语言大版内专家分月排行榜第二2014年5月 其他开发语言大版内专家分月排行榜第二2014年4月 其他开发语言大版内专家分月排行榜第二2014年3月 其他开发语言大版内专家分月排行榜第二2014年1月 其他开发语言大版内专家分月排行榜第二2013年12月 其他开发语言大版内专家分月排行榜第二2013年11月 其他开发语言大版内专家分月排行榜第二2013年3月 其他开发语言大版内专家分月排行榜第二2012年5月 其他开发语言大版内专家分月排行榜第二2012年4月 其他开发语言大版内专家分月排行榜第二2010年10月 其他开发语言大版内专家分月排行榜第二2010年9月 其他开发语言大版内专家分月排行榜第二
2013年9月 其他开发语言大版内专家分月排行榜第三2012年6月 其他开发语言大版内专家分月排行榜第三
2014年8月 其他开发语言大版内专家分月排行榜第二2014年7月 其他开发语言大版内专家分月排行榜第二2014年5月 其他开发语言大版内专家分月排行榜第二2014年4月 其他开发语言大版内专家分月排行榜第二2014年3月 其他开发语言大版内专家分月排行榜第二2014年1月 其他开发语言大版内专家分月排行榜第二2013年12月 其他开发语言大版内专家分月排行榜第二2013年11月 其他开发语言大版内专家分月排行榜第二2013年3月 其他开发语言大版内专家分月排行榜第二2012年5月 其他开发语言大版内专家分月排行榜第二2012年4月 其他开发语言大版内专家分月排行榜第二2010年10月 其他开发语言大版内专家分月排行榜第二2010年9月 其他开发语言大版内专家分月排行榜第二
2013年9月 其他开发语言大版内专家分月排行榜第三2012年6月 其他开发语言大版内专家分月排行榜第三
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。【python】为什么import pg会出错呢?
[问题点数:30分]
【python】为什么import pg会出错呢?
[问题点数:30分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2012年1月 其他开发语言大版内专家分月排行榜第二2011年5月 其他开发语言大版内专家分月排行榜第二2010年12月 其他开发语言大版内专家分月排行榜第二2009年2月 其他开发语言大版内专家分月排行榜第二2008年9月 其他开发语言大版内专家分月排行榜第二2008年8月 其他开发语言大版内专家分月排行榜第二2008年5月 其他开发语言大版内专家分月排行榜第二2007年11月 其他开发语言大版内专家分月排行榜第二
2011年4月 其他开发语言大版内专家分月排行榜第三2011年1月 其他开发语言大版内专家分月排行榜第三2009年6月 其他开发语言大版内专家分月排行榜第三2009年4月 其他开发语言大版内专家分月排行榜第三2009年1月 其他开发语言大版内专家分月排行榜第三2008年11月 其他开发语言大版内专家分月排行榜第三2008年7月 其他开发语言大版内专家分月排行榜第三2008年6月 其他开发语言大版内专家分月排行榜第三2006年9月 其他开发语言大版内专家分月排行榜第三
2014年8月 其他开发语言大版内专家分月排行榜第二2014年7月 其他开发语言大版内专家分月排行榜第二2014年5月 其他开发语言大版内专家分月排行榜第二2014年4月 其他开发语言大版内专家分月排行榜第二2014年3月 其他开发语言大版内专家分月排行榜第二2014年1月 其他开发语言大版内专家分月排行榜第二2013年12月 其他开发语言大版内专家分月排行榜第二2013年11月 其他开发语言大版内专家分月排行榜第二2013年3月 其他开发语言大版内专家分月排行榜第二2012年5月 其他开发语言大版内专家分月排行榜第二2012年4月 其他开发语言大版内专家分月排行榜第二2010年10月 其他开发语言大版内专家分月排行榜第二2010年9月 其他开发语言大版内专家分月排行榜第二
2013年9月 其他开发语言大版内专家分月排行榜第三2012年6月 其他开发语言大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。今天看啥 热点:
ubuntu上跑python连接pg,报错
ImportError: No module named psycopg2,ubuntupython
ubuntu上跑python连接pg,报错 &ImportError: No module named psycopg2
root@pgproxy1:~# python /home/zxw/PGWriterTest_m.py&
Traceback (most recent call last):
& File &/home/zxw/PGWriterTest_m.py&, line 4, in &module&
& & import psycopg2
ImportError: No module named psycopg2
如下安装:
root@pgproxy1:~# apt-cache search psycopg2
python-psycopg2 - Python module for PostgreSQL
python-psycopg2-dbg - Python module for PostgreSQL (debug extension)
python-psycopg2-doc - Python module for PostgreSQL (documentation package)
python3-psycopg2 - Python 3 module for PostgreSQL
python3-psycopg2-dbg - Python 3 module for PostgreSQL (debug extension)
root@pgproxy1:~# python -V
Python 2.7.3
root@pgproxy1:~# apt-get install -y python-psycopg2 python-psycopg2-doc python-psycopg2-dbg
Reading package lists... Done
Building dependency tree & & &&
Reading state information... Done
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@pgproxy1:~#
脚本如下:
# --encoding:utf-8--
import time
import threading
import psycopg2
import Queue
import datetime
class PGWriterTest(threading.Thread):
& & &&& 初始化 &&&
& & def __init__(self,connstr):
& & & & self.conn = psycopg2.connect(connstr)
& & & & self.cursor = self.conn.cursor()
& & & & self.dbnum &= 4
& & & & self.connArray = []
& & & & self.cursorArray = []
& & & & for i in range(0,self.dbnum):
& & & & & & #DB port
& & & & & & dbidstr = '%02d' % (9900 + i)
& & & & & & if (i == 0 &or i == 2 ):
& & & & & & & & dstDB = 'host=ip1 user=dbusername password=pwd dbname=dbname port='+ dbidstr
& & & & & & else:
& & & & & & & & dstDB = 'host=ip2 user=dbusername password=pwd dbname=dbname port='+ dbidstr
& & & & & & print 'connect ' + dstDB
& & & & & &
& & & & & & dstConn = &psycopg2.connect(dstDB)
& & & & & & self.connArray.append(dstConn)
& & & & & & dstCursor = dstConn.cursor()
& & & & & & self.cursorArray.append(dstCursor)
& & & & # 运行父类的构造函数
& & & & threading.Thread.__init__(self)
& & &&& 数据写入数据库 &&&&
& & def read(self,t_id):
& & & & sql = 'SELECT * from get_cont('+str(t_id)+')'&
& & & & self.cursor.execute(sql)
& & & & datalist = []
& & & & for row in self.cursor.fetchall():
& & & & & & datalist.append(row)
& & & & return datalist & &
& & &&& 数据写入数据库 &&&&
& & def save(self,t_id,data):
& & & & sql = 'SELECT write_cont((%s,character(255) %s,%d,NOW()::timestamp))'
& & & & params = []
& & & & params.append(t_id)
& & & & params.append(data[1])
& & & & params.append(data[2])
& & & & params.append(data[3])
& & & & #print params
& & & & #取db_ins_id
& & & & db_ins_id = 0
& & & & db_ins_id = t_id % self.dbnum
& & & & try:
& & & & & & print str(datetime.datetime.now()) + & DB & + str(db_ins_id) + & & + &str( t_id ) + & before insert&
& & & & & & insert_sql = 'SELECT write_cont((%s,character(255) %s,%d,NOW()::timestamp))'
& & & & & & self.cursorArray[db_ins_id].execute(insert_sql,params)
& & & & & & self.cursorArray[db_ins_id].execute(&COMMIT&)
& & & & & & print str(datetime.datetime.now()) + & DB & + str(db_ins_id) + & & + &str( t_id ) + & inserted&
& & & & & & return True
& & & & except Exception,ex:
& & & & & & print(&save error:%s& % str(ex))
& & & & & & print(&save t_id:%s\t& % str(t_id))
& & & & & & print(&error cont:%s& % str(params))
& & & & & & #self.log.write(&error param:%s& % str(params))
& & & & & & #self.log.write(&error t_id:%s& % data.get('t_id',''))
& & & & & & self.cursorArray[db_ins_id].execute(&ROLLBACK&)
& & & & & & return False
& & & & & &&
& & & & & & #测试读取
& & & & & & &&&
& & & & & & try:
& & & & & & & & searchsql = 'select t_id from get_cont('+ str(t_id) + ')'
& & & & & & & & self.cursorArray[db_ins_id].execute(searchsql)
& & & & & & & & data = self.cursorArray[db_ins_id].fetchone()
& & & & & & & & if (data == None &or int(data[0]) != t_id ):
& & & & & & & & & & print ' insert error for ' +str(db_ins_id) + searchsql
& & & & & & except Exception,searchex:
& & & & & & & & print str(searchex) + ' for &' + searchsql
& & & & & & &&& & &&
& & & & return True
if __name__ == &__main__&:
& & pgTest = PGWriterTest('host=ip user=DBUser password=pwd dbname=DBNAme port=9999')
& & start_time = &str(datetime.datetime.now())
& & for i in range(1,10):
& & & & t_id = 1000 +
& & & & print str(datetime.datetime.now()) + & getting &
& & & & rows = pgTest.read(t_id)
& & & & print str(datetime.datetime.now()) + & gotten &
& & & & #print rows[0]
& & & & pgTest.save(t_id,rows[0])
& & print start_time
& & print &str(datetime.datetime.now())
-----------------&
转载请著明出处:
blog.csdn.net/beiigang
这个是postgreSQL的一个接口。需要单独安装。如果你已经安装了。还显示这个错误。你可以从源代码那里重新安装一次。看看有没有安装错误。另外你的计算机上是不是有两份python,你安装到了另一外目录里。
2.5之前的版本是不包含hashlib的,你需要自己安装pypi.python.org/pypi/hashlibThis is a stand alone packaging of the hashlib library included with Python 2.5 so that it can be used on older versions of Python (tested on 2.3 and 2.4).参考资料:/
相关搜索:
相关阅读:
相关频道:
&&&&&&&&&&&&&&&&&&&&&&&&&&&&
数据库前沿最近更新}

我要回帖

更多关于 import java.io出错 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信