`
zhanyingle_1981
  • 浏览: 325513 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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即可。

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics