Python Django Riak 这几天的调试

最近这几天被python的调试给折腾的无语了。。。。。。。。。

 

1. 在apache下log调试,出的比较明显的错,在log中根本看不出来,最后只能一步一步log,才找到出错的地方,诚心折腾人

2. 发现在交互命令时,因为我自己的代码中有个叫collection的module,结果import riak时出错:

>>> import riak
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/riak-1.4.0-py2.6.egg/riak/__init__.py", line 39, in <module>
    from riak_object import RiakObject
  File "/usr/local/lib/python2.6/dist-packages/riak-1.4.0-py2.6.egg/riak/riak_object.py", line 668, in <module>
    from mapreduce import *
  File "/usr/local/lib/python2.6/dist-packages/riak-1.4.0-py2.6.egg/riak/mapreduce.py", line 20, in <module>
    import urllib
  File "/usr/lib/python2.6/urllib.py", line 30, in <module>
    from urlparse import urljoin as basejoin
  File "/usr/lib/python2.6/urlparse.py", line 105, in <module>
    from collections import namedtuple
ImportError: cannot import name namedtuple

 

Stack Overflow上有人回答:

Looks like there's another module in your Python path named collections (probably collections.py but could also be a folder named collections that has an __init__.py in it) that's preventing the Python 2.6 collections module from being imported. Could be something in the directory that's current when you invoke Python -- check there first. Otherwise try python26 -c 'import sys; print sys.path' to see where Python's looking for modules.

 

/usr/local/lib/python2.7/site-packages/

 

3. sqlite3 查看表sql:select * FROM Sqlite_master where type='table'.

 

4. python 多版本切换

/usr/bin/python和/usr/local/bin/python下面,一般是符号链接,优先使用后者,

如果有2.6和2.7两个版本,并且
/usr/bin/python --> /usr/bin/python2.6
/usr/local/bin/python --> /usr/local/bin/python2.7
此时系统默认使用2.7, 如果想切换至2.6

直接用  sudo ln -s /usr/local/bin/python /usr/bin/python2.6即可。

 

Resotre Now
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值