gpt4 book ai didi

python - 使用Stanfordcorenlp发生PermissionError : [Errno 1] Operation not permitted

转载 作者:行者123 更新时间:2023-12-03 07:44:17 25 4
gpt4 key购买 nike

我正在做一个与NLP相关的项目,因此决定使用standfordcorenlp。但是,当我尝试实现这些代码时,会出现错误。以下是我的代码以及控制台上显示的内容:

from stanfordcorenlp import StanfordCoreNLP

nlp = StanfordCoreNLP(r'/Users/xiehang/PycharmProjects/Autism/stanford-corenlp-full-2018-02-27')
sentence = 'Enviroment is really important.'
print (nlp.ner(sentence))
nlp.close();

控制台将输出:

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
/Users/xiehang/PycharmProjects/Autism/NER.py Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil/_psosx.py", line 330, in wrapper return fun(self, *args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil/_psosx.py", line 515, in connections rawlist = cext.proc_connections(self.pid, families, types) PermissionError: [Errno 1] Operation not permitted



在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last): File "/Users/xiehang/PycharmProjects/Autism/NER.py", line 9, in nlp = StanfordCoreNLP(r'/Users/xiehang/PycharmProjects/Autism/stanford-corenlp-full-2018-02-27') File "/Library/Frameworks/Python.framework/Versions/3.6/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 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil/init.py", line 2108, in net_connections return _psplatform.net_connections(kind) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil/_psosx.py", line 249, in net_connections cons = Process(pid).connections(kind) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil/_psosx.py", line 335, in wrapper raise AccessDenied(self.pid, self._name) psutil._exceptions.AccessDenied: psutil.AccessDenied (pid=707)

Process finished with exit code 1



我搜索了几乎所有可能的网站,试图找出它的几天,这非常痛苦。我真的希望有人能帮助我解决。谢谢!

最佳答案

我有类似的问题,我通过通过sudo运行代码来解决了。这是我的情况:

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

因此,您将执行以下操作:
sudo /Your_python_location/python3 /Users/xiehang/PycharmProjects/Autism/NER.py

希望这也对您有用。

关于python - 使用Stanfordcorenlp发生PermissionError : [Errno 1] Operation not permitted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49333254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com