在合并多处理、请求(或urllib2)和nltk时,我遇到了一个问题。下面是一个非常简单的代码:
>>> from multiprocessing import Process
>>> import requests
>>> from pprint import pprint
>>> Process(target=lambda: pprint(
requests.get('https://api.github.com'))).start()
>>> <Response [200]> # this is the response displayed by the call to `pprint`.关于这段代码做什么的更多细节:
效果很好。问题出现在导入nltk时:
>>> import nltk
>>> Process(target=lambda: pprint(
requests.get('https://api.github.com'))).start()
>>> # nothing happens!在导入了NLTK之后,请求实际上悄悄地崩溃了线程(如果您尝试使用一个命名函数而不是lambda函数,在调用之前和之后添加几个print语句,您将看到在调用requests.get时执行就停止了),是否有人知道NLTK中有什么可以解释这种行为,以及如何克服这个问题?
下面是我使用的版本:
$> python --version
Python 2.7.5
$> pip freeze | grep nltk
nltk==2.0.5
$> pip freeze | grep requests
requests==2.2.1我在运行Mac v.10.9.5。
谢谢!
发布于 2016-10-12 22:48:31
这个问题似乎还没有解决。https://github.com/nltk/nltk/issues/947我认为这是一个严重的问题(除非你在玩NLTK,做POCs和试用模型,而不是实际的应用程序),我正在RQ (http://python-rq.org/)中运行NLP管道。
nltk==3.2.1
requests==2.9.1https://stackoverflow.com/questions/30766419
复制相似问题