最近这几天被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 多版本切换