如何解决PyCharm 上未解决的引用“rasa_nlu”
我正在 PyCharm IDE 和 Mac OSX 上开发 rasa 项目,并且我正在尝试创建自定义组件类:
from rasa_nlu.components import Component
from rasa.nlu import utils
from rasa.nlu.model import Metadata
import nltk
import os
from profanity_filter import ProfanityFilter
class ProfanityAnalyzer(Component):
name="profanity_analyzer"
provides = []
requries = ["entities"]
deafults = {}
language_list = ["en"]
def __init__(self,component_config=None):
super(ProfanityAnalyzer,self).__init__(component_config)
def train(self,training_data,cfg,**kwargs):
"""Load the sentiment polarity labels from the text
file,retrieve training tokens and after formatting
data train the classifier."""
def convert_to_rasa(self,value,confidence):
entity = {"value":value,"confidence":confidence,"entity":"profane_word","extractor":"profanity_extractor"}
return entity
def process(self,message,**kwargs):
pf=ProfanityFilter()
text=message.text
if pf.is_profane(text):
tokens=text.split(" ")
for token in tokens:
if pf.is_profane(token):
value=token
confidence=100
entity = self.convert_to_rasa(value,confidence)
message.set("entities",[entity],add_to_output=True)
def persist(self,file_name,model_dir):
"""Persist this model into the passed directory."""
我尝试通过以下命令通过终端安装 rasa nlu:
pip install rasa_nlu
它给出了这个错误:
Collecting rasa_nlu
Using cached rasa_nlu-0.15.1-py3-none-any.whl (147 kB)
Requirement already satisfied: boto3~=1.9 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from rasa_nlu) (1.16.47)
Requirement already satisfied: tqdm~=4.19 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from rasa_nlu) (4.50.2)
Requirement already satisfied: numpy>=1.16 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from rasa_nlu) (1.18.5)
Requirement already satisfied: requests~=2.20 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from rasa_nlu) (2.25.1)
Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from boto3~=1.9->rasa_nlu) (0.3.3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from boto3~=1.9->rasa_nlu) (0.10.0)
Requirement already satisfied: botocore<1.20.0,>=1.19.47 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from boto3~=1.9->rasa_nlu) (1.19.47)
Requirement already satisfied: urllib3<1.27,>=1.25.4 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from botocore<1.20.0,>=1.19.47->boto3~=1.9->rasa_nlu) (1.26.2)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from botocore<1.20.0,>=1.19.47->boto3~=1.9->rasa_nlu) (2.8.1)
Collecting cloudpickle~=0.6.1
Using cached cloudpickle-0.6.1-py2.py3-none-any.whl (14 kB)
Collecting coloredlogs~=10.0
Using cached coloredlogs-10.0-py2.py3-none-any.whl (47 kB)
Requirement already satisfied: humanfriendly>=4.7 in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from coloredlogs~=10.0->rasa_nlu) (9.1)
Collecting future~=0.17.1
Using cached future-0.17.1.tar.gz (829 kB)
Collecting gevent~=1.3
Using cached gevent-1.5.0-cp38-cp38-macosx_10_9_x86_64.whl (1.8 MB)
Collecting greenlet>=0.4.14
Using cached greenlet-0.4.17.tar.gz (61 kB)
Collecting jsonschema~=2.6
Using cached jsonschema-2.6.0-py2.py3-none-any.whl (39 kB)
Collecting klein~=17.10
Using cached klein-17.10.0-py2.py3-none-any.whl (30 kB)
Requirement already satisfied: werkzeug in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from klein~=17.10->rasa_nlu) (1.0.1)
Requirement already satisfied: six in ./opt/anaconda3/envs/allProjects/venv/lib/python3.8/site-packages (from klein~=17.10->rasa_nlu) (1.15.0)
Collecting matplotlib~=2.2
Using cached matplotlib-2.2.5.tar.gz (36.7 MB)
ERROR: Command errored out with exit status 1:
command: /Users/zahraaal-nemer/opt/anaconda3/envs/allProjects/venv/bin/python -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/private/var/folders/sm/bjkmpsf90ng76c26v82cg1j80000gn/T/pip-install-w584fd2l/matplotlib_052328d9a48d4df5b2eccca54a9fc129/setup.py'"'"'; __file__='"'"'/private/var/folders/sm/bjkmpsf90ng76c26v82cg1j80000gn/T/pip-install-w584fd2l/matplotlib_052328d9a48d4df5b2eccca54a9fc129/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/sm/bjkmpsf90ng76c26v82cg1j80000gn/T/pip-pip-egg-info-t9qjhxas
cwd: /private/var/folders/sm/bjkmpsf90ng76c26v82cg1j80000gn/T/pip-install-w584fd2l/matplotlib_052328d9a48d4df5b2eccca54a9fc129/
Complete output (106 lines):
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [2.2.5]
python: yes [3.8.5 (default,Sep 4 2020,02:22:02) [Clang
10.0.0 ]]
platform: yes [darwin]
required DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.18.5]
install_requires: yes [handled by setuptools]
libagg: yes [pkg-config information for 'libagg' Could not
be found. Using local copy.]
freetype: no [The C/C++ header for freetype2 (ft2build.h)
Could not be found. You may need to install the
development package.]
png: no [pkg-config information for 'libpng' Could not
be found.]
qhull: yes [pkg-config information for 'libqhull' Could not
be found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: no [skipping due to configuration]
toolkits_tests: no [skipping due to configuration]
OPTIONAL BACKEND EXTENSIONS
macosx: yes [installing,darwin]
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
qt5agg: no [pyside2 not found; PyQt5 not found]
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
qt4agg: no [PySide not found; PyQt4 not found]
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
gtk3agg: no [Requires pygobject to be installed.]
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: yes [installing; run-time loading from Python Tcl /
Tk]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: no [Microsoft Windows only]
OPTIONAL LATEX DEPENDENCIES
dvipng: no
ghostscript: no
latex: no
pdftops: no
OPTIONAL PACKAGE DATA
dlls: no [skipping due to configuration]
============================================================================
* The following required packages can not be built:
* freetype,png
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方法
rasa_nlu 和 profanity_filter 都安装了吗?
看看 PyCharm 设置。浏览到项目设置 -> Python 解释器。显示所有已安装的外部软件包的列表。他们在场吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。