python-3.x - 尝试加载 StanfordCoreNLP 时出现 psutil.AccessDenied 错误

标签 python-3.x nlp connection stanford-nlp psutil

我正在尝试加载包 StanfordCoreNLP 以正确解析其页面 (https://nlp.stanford.edu/sentiment/treebank.html) 中显示的电影评论:(我使用的是 MAC)

nlp = StanfordCoreNLP("/Users//NLP_models/stanford-corenlp-full-2018-01-31")

但是得到错误:

Traceback (most recent call last):
  File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 295, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 480, in connections
    rawlist = cext.proc_connections(self.pid, families, types)
PermissionError: [Errno 1] Operation not permitted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 2411, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1802, in run
    launch(file, globals, locals)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc) 

...
...
...

File "/Users/anaconda3/lib/python3.6/site-packages/stanfordcorenlp/corenlp.py", line 79, in __init__
if port_candidate not in [conn.laddr[1] for conn in psutil.net_connections()]:

File "/Users/anaconda3/lib/python3.6/site-packages/psutil/__init__.py", line 2191, in net_connections
    return _psplatform.net_connections(kind)
  File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 229, in net_connections
    cons = Process(pid).connections(kind)
  File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 300, in wrapper
    raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=5488)

我试过了

conda update conda
conda update anaconda-navigator
conda update navigator-updater

但这并没有帮助。 有什么想法吗??

谢谢!!

最佳答案

我有同样的问题,我通过使用 sudo 运行代码来解决问题,如下所示:

sudo /Users/edamame/workspace/git/chinese_nlp/venv/bin/python3 chinese_segmenter1.py

希望这对你也有用。

关于python-3.x - 尝试加载 StanfordCoreNLP 时出现 psutil.AccessDenied 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49100525/

相关文章:

python - 如何使用条件语句创建包含计算值的新列

python - 如何按 block 将函数应用于 Pandas 数据框?

r - 如何同时逐行读取和写入文件?

python - python中的Celery构建微服务

mysql - Python 数据插入的 SQL 死锁

python - NLTK punkt 的训练数据格式

python - 在 Tensorflow 2.0/Keras 中使用其他数据功能创建文本分类器

machine-learning - 识别区分类别时最有用的单词

php - Laravel MySQL SQLSTATE[HY000] [2002] 连接被拒绝

.net - 如何让 WCF 自动关闭连接?