V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  yucongo  ›  全部回复第 7 页 / 共 7 页
回复总数  140
1  2  3  4  5  6  7  
2017-07-02 01:24:11 +08:00
回复了 yucongo 创建的主题 Python Windows 下 Python 3 出 segfault 时如何找错?
貌似 Windows 下 Python 3 要找 segfault 出错的地方没有什么办法。再加上我的程序还是 wxpython GUI,完全没辙。我试过 Windbg,winpdb,trepan3k,pudb, 都不行。

Windbg 里用 pykd 可以运行 python 非 GUI 程序,运行 wxpython 写的 gui 程序就出不来 gui。也可以在 python 下运行 wxpython 写的 gui 程序后 attach 到 Windbg, 但 attach 后 wxpython gui 就没有反应了, 也就是说没法 gui 里的交互(点击、载入文件啊什么的)。

最后还是靠 logging …… 找到 python 一个 bug:

os.startfile("")

python ( 2.7, 3.4, 3.5 )直接死掉。try... except ... 没有用…… 花掉我一整天 ……&¥……%¥#
2017-07-01 12:55:29 +08:00
回复了 yucongo 创建的主题 Python Windows 下 Python 3 出 segfault 时如何找错?
@zk8802 感谢。我试试……
2017-07-01 12:10:47 +08:00
回复了 yucongo 创建的主题 Python Windows 下 Python 3 出 segfault 时如何找错?
certifi==2017.4.17
chardet==3.0.2
colorama==0.3.9
configobj==5.0.6
cx-Freeze==5.0.2
future==0.16.0
googletrans==2.1.3
html2text==2016.9.19
langdetect==1.0.7
langid==1.1.6
lxml==3.7.3
nltk==3.2.2
nose==1.3.7
numpy==1.13.0
pandas==0.20.2
py==1.4.34
pycountry==17.1.8
pysrt==1.1.1
pysubs2==0.2.1
pytest==3.1.2
python-dateutil==2.6.0
python-docx==0.8.6
pytz==2017.2
pywin32==221
PyYAML==3.12
regex==2017.4.29
requests==2.13.0
requests-cache==0.4.13
segtok==1.5.5
six==1.10.0
textblob==0.12.0
tqdm==4.11.2
wxPython==4.0.0a2.dev3016+2645796
xlrd==1.0.0
yandex.translate==0.3.5

@ipwx Python 3.5 venv 下 pip freeze 的包

因为看不懂 stack trace,所以一直在整 gdb-python,不过我试着用 gdb 在 Python 3 下获取 stack trace,成功的话在贴上来。
2017-07-01 12:02:26 +08:00
回复了 yucongo 创建的主题 Python Windows 下 Python 3 出 segfault 时如何找错?
@congeec 感谢提供信息。我想我会用 MinGW 试试。如果你有有关资料能提供一些链接什么的就更加感谢了。
2017-07-01 11:15:12 +08:00
回复了 yucongo 创建的主题 Python Windows 下 Python 3 出 segfault 时如何找错?
@XYxe 感谢。先记下来研究一下。VS 好像太大了,而且我的机器比较旧,怕是拖不动 VS。
2017-07-01 10:56:02 +08:00
回复了 yucongo 创建的主题 Python Windows 下 Python 3 出 segfault 时如何找错?
感谢楼上 @ipwx、 @dbow 二位。

不管是 native package 还是代码问题,都是想先找到出错的原因。gdb 貌似不能给出出错的 python 源码位置。看 stackoverflow 里说,gdb-python 倒是可以给出 python 源码位置。但 gdb-python 在 windows 里只能用于 Python 2. 我已经花了一天试着将我的 Python 3 改成 Python 2. 太麻烦、太乱,只好放弃。
2017-07-01 10:40:03 +08:00
回复了 yucongo 创建的主题 Python Windows 下 Python 3 出 segfault 时如何找错?
@dbow 出 segfault 是没有错误信息的,整个 python 死掉。
2017-06-28 00:40:47 +08:00
回复了 donglongtu 创建的主题 Python Python 统计某一文件夹下文件数量
from pathlib import Path # Py3 自带
dir_path = '.'
print(len(list(Path(dir_path).iterdir()))
2017-06-25 01:40:12 +08:00
回复了 a554340466 创建的主题 程序员 自搭网盘有什么好方案吗
resilio sync 或 syncthing
@Jackeriss 感谢。

不过 snownlp 的分句逗号处也分了。

zh = snownlp.SnowNLP('非中文分句,nltk 里的 tokenizer 可处理各种语言(其实是用 nltk 里的 pickle 文件),可惜用了 nltk 的 Python 程序生成 exe 包时麻烦多多,因为 nltk 的 data 目录结构不在 python lib 下。另外 github 上有个 segtok 项目,好像还可以用,但性能不如 nltk。')
zh.sentences
['非中文分句',
'nltk 里的 tokenizer 可处理各种语言(其实是用 nltk 里的 pickle 文件)',
'可惜用了 nltk 的 Python 程序生成 exe 包时麻烦多多',
'因为 nltk 的 data 目录结构不在 python lib 下',
'另外 github 上有个 segtok 项目',
'好像还可以用',
'但性能不如 nltk']

而且标点符号也没了。估计是简单用 re.split 做的。

snwonlp 想做成中文版 textblob, 可惜在分句上没做足功夫。

textblob 的分句:
blob = textblob.TextBlob('The rider sits on and operates these vehicles like a motorcycle, but the extra wheels give more stability at slower speeds. Although equipped with three or four wheels, six-wheel models exist for specialized applications. Engine sizes of ATVs currently for sale in the United States, (as of 2008 products), range from 49 to 1,000 cc (3 to 61 cu in).')
blob.sentences
[Sentence("The rider sits on and operates these vehicles like a motorcycle, but the extra wheels give more stability at slower speeds."),
Sentence("Although equipped with three or four wheels, six-wheel models exist for specialized applications."),
Sentence("Engine sizes of ATVs currently for sale in the United States, (as of 2008 products), range from 49 to 1,000 cc (3 to 61 cu in).")]
2017-06-17 17:46:12 +08:00
回复了 quietjosen 创建的主题 Python 0612 - 我入门 Python 后总结的基础教程
肯定要学 Python 3 啦老大……
2017-06-17 17:31:03 +08:00
回复了 sundays 创建的主题 自然语言处理 python 分句小技巧-大神的日常
[...] 的用法貌似有少少问题,不像是大神级写出来的正则,那些"|"不是在[...]里用的东西,或者是你抄错了?
pdir2 不错,感谢一下 XYxe。也感谢一下提问者,我也在有过同样的疑问,比如 pathlib 里的 Path 不知道哪个是属性、哪个是方法……
@0asis 分句
2017-06-17 13:50:31 +08:00
回复了 a282810 创建的主题 Python 请教一下关于 Python 脚本打包成单一 exe 文件的问题
cxfreeze 还不错,Windows 7 + Python 3.4 下打过 wxpython 包、pyqt 包,都可以用(有些第三方 python 包要用直接拷的办法),不过 cxfreeze 不支持打包成单 exe 文件。
2017-05-26 18:30:29 +08:00
回复了 bozong 创建的主题 Python 有用过 Py 写桌面程序的嘛。来瞅瞅。。。。。。
简单一点的程序用 wxpython + wxformbuilder + cx_freeze, 界面比 tkinter 好看点,但还是比较丑,google driver 终端是用 wxpython 写的

复杂一点的程序用 pyqt/pyside + qt designer + cx_freeze, Anki/Calibre/Dropbox 终端是用 PyQt 写的
2017-04-19 23:51:16 +08:00
回复了 JasperYanky 创建的主题 Python Python3 处理中文问题
可以是国人的网页没跟足标准, 试试 resp.encoding='utf-8':
url = '...'
resp = requests.get(url)
resp.encoding = 'UTF-8'

=====
In [189]: url = 'http://www.baidu.com'

In [190]: import requests

In [191]: resp = requests.get(url)

In [192]: resp.encoding
Out[192]: 'ISO-8859-1' # bad !

In [200]: chardet.detect(resp.content)
Out[200]: {'confidence': 0.99, 'encoding': 'utf-8'}

In [201]: resp.encoding = 'utf-8'
2017-04-15 15:37:55 +08:00
回复了 tianshilei1992 创建的主题 Python Python 下多进程的问题
试试
p.daemon = True
p.start()
2017-04-13 23:17:09 +08:00
回复了 zzcchh 创建的主题 Python 谷歌翻译的一个可用网页接口
requests 的 response 里其实有 json 数据!

不够钱帖源码, 参看 https://github.com/yucongo/mgoogle_translategoogleapis_translate.py ( Python 3.4 Win7 )
2017-04-13 23:07:43 +08:00
回复了 fearme 创建的主题 Python Python 字符串转数字的问题
Python 3.4:

a_str = '...'
from contextlib import suppress
with suppress(Exception): a_str = float(a_str)

# a_str 可转 float 的话到这里就是 float 了, 不能转就还是 str
' %s 可转 float :%s ' % (a_str, isinstance(a_str, float))

E.g.:

from contextlib import suppress

a_str = 'abc'
with suppress(Exception): a_str = float(a_str)
' %s 可转 float :%s ' % (a_str, isinstance(a_str, float)) $ False

a_str = '3.4'
with suppress(Exception): a_str = float(a_str)
' %s 可转 float :%s ' % (a_str, isinstance(a_str, float)) # True

a_str = 'NaN'
with suppress(Exception): a_str = float(a_str)
' %s 可转 float :%s ' % (a_str, isinstance(a_str, float)) # True

a_str = 'Nan'
with suppress(Exception): a_str = float(a_str)
' %s 可转 float :%s ' % (a_str, isinstance(a_str, float)) # True

a_str = 'inf'
with suppress(Exception): a_str = float(a_str)
' %s 可转 float :%s ' % (a_str, isinstance(a_str, float)) # True
1  2  3  4  5  6  7  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2176 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms · UTC 11:38 · PVG 19:38 · LAX 04:38 · JFK 07:38
Developed with CodeLauncher
♥ Do have faith in what you're doing.