目录
1、rasa配置开发环境
1.1windows安装步骤:
1.2 激活建立的虚拟环境:
1.3 安装rasa
2、安装Visual Studio
第一步:进入官网:Visual Studio: IDE and Code Editor for Software Developers and Teams下载社区版
第二步:双击安装包,进入安装步骤。
第三步,选择安装的组件以及位置
第4步添加环境变量
第5步:重启,进入anaconda 中的rasa环境
3 安装Mitie
3.1 在线安装mitie(不建议)
3.2 离线安装mitie
第一步:下载mite源码
第二步:安装
4 、安装jieba
5 、安装Rasa Core
6、安装rasa_nlu
7、一次性安装所依赖的所有库
8 anaconda+pycharm配置:
9、创建经典案例
1、rasa配置开发环境
1.1windows安装步骤:
打开ancona prompt命令窗口
使用anaconda进行安装rasa:
1 anaconda 命令创建python版本为X.X、名字为rasaEnv的虚拟环境。
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6"><span style="color:#f07178">conda</span> <span style="color:#f07178">create</span> <span style="color:#89ddff">-</span><span style="color:#f07178">n</span> <span style="color:#f07178">rasaEnv</span> <span style="color:#f07178">python</span>=<span style="color:#ff5370">3.7</span></span></span>
注意:使用pip安装Rasa开放源码(需要Python3.7或3.8)。
使用命令,查看安装情况:
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6"><span style="color:#f07178">conda</span> <span style="color:#f07178">info</span> <span style="color:#89ddff">--</span><span style="color:#f07178">env</span></span></span>
?
1.2 激活建立的虚拟环境:
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6"><span style="color:#f07178">activate</span> <span style="color:#f07178">rasaEnv</span></span></span>
1.3 安装rasa
为增加下载速度,提前在anaconda中,在刚刚激活的rasa环境中,配置清华镜像源
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6"><span style="color:#f07178">conda</span> <span style="color:#f07178">config</span> <span style="color:#89ddff">--</span><span style="color:#f07178">add</span> <span style="color:#f07178">channels</span> <span style="color:#f07178">https</span>:<span style="color:#89ddff">//</span><span style="color:#f07178">mirrors</span>.<span style="color:#c792ea">tuna</span>.<span style="color:#c792ea">tsinghua</span>.<span style="color:#c792ea">edu</span>.<span style="color:#c792ea">cn</span><span style="color:#89ddff">/</span><span style="color:#f07178">anaconda</span><span style="color:#89ddff">/</span><span style="color:#f07178">pkgs</span><span style="color:#89ddff">/</span><span style="color:#f07178">free</span><span style="color:#89ddff">/</span>
<span style="color:#f07178">conda</span> <span style="color:#f07178">config</span> <span style="color:#89ddff">--</span><span style="color:#f07178">add</span> <span style="color:#f07178">channels</span> <span style="color:#f07178">https</span>:<span style="color:#89ddff">//</span><span style="color:#f07178">mirrors</span>.<span style="color:#c792ea">tuna</span>.<span style="color:#c792ea">tsinghua</span>.<span style="color:#c792ea">edu</span>.<span style="color:#c792ea">cn</span><span style="color:#89ddff">/</span><span style="color:#f07178">anaconda</span><span style="color:#89ddff">/</span><span style="color:#f07178">pkgs</span><span style="color:#89ddff">/</span><span style="color:#f07178">main</span><span style="color:#89ddff">/</span>
?
<span style="color:#f07178">conda</span> <span style="color:#f07178">config</span> <span style="color:#89ddff">--</span><span style="color:#f07178">add</span> <span style="color:#f07178">channels</span> <span style="color:#f07178">https</span>:<span style="color:#89ddff">//</span><span style="color:#f07178">mirrors</span>.<span style="color:#c792ea">tuna</span>.<span style="color:#c792ea">tsinghua</span>.<span style="color:#c792ea">edu</span>.<span style="color:#c792ea">cn</span><span style="color:#89ddff">/</span><span style="color:#f07178">anaconda</span><span style="color:#89ddff">/</span><span style="color:#f07178">cloud</span><span style="color:#89ddff">/</span><span style="color:#f07178">conda</span><span style="color:#89ddff">-</span><span style="color:#f07178">forge</span><span style="color:#89ddff">/</span>
<span style="color:#f07178">conda</span> <span style="color:#f07178">config</span> <span style="color:#89ddff">--</span><span style="color:#f07178">add</span> <span style="color:#f07178">channels</span> <span style="color:#f07178">https</span>:<span style="color:#89ddff">//</span><span style="color:#f07178">mirrors</span>.<span style="color:#c792ea">tuna</span>.<span style="color:#c792ea">tsinghua</span>.<span style="color:#c792ea">edu</span>.<span style="color:#c792ea">cn</span><span style="color:#89ddff">/</span><span style="color:#f07178">anaconda</span><span style="color:#89ddff">/</span><span style="color:#f07178">cloud</span><span style="color:#89ddff">/</span><span style="color:#f07178">msys2</span><span style="color:#89ddff">/</span> ? ?
<span style="color:#f07178">conda</span> <span style="color:#f07178">config</span> <span style="color:#89ddff">--</span><span style="color:#ffcb6b">set</span> <span style="color:#f07178">show_channel_urls</span> <span style="color:#f07178">yes</span></span></span>
或者在文件夹目录C:\Users\用户名.condarc,进行配置
执行安装命令
注意:安装过程会自动安装keras 、tensorflow
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6"><span style="color:#f07178">pip</span> <span style="color:#f07178">install</span> <span style="color:#f07178">rasa</span></span></span>
2、安装Visual Studio
在线安装mitie时,成功率太低,且在rasa训练过程中,容易报错,故在安装mitie之前安装visual Studio。具体步骤如下:
第二步:双击安装包,进入安装步骤。
?
第三步,选择安装的组件以及位置
1 因为我不涉及其他的开发,我只选择了基础的C++开发工具。
?
2 单击【单个组件】,勾选 用于 CMake 的 Visual C++ 工具
?
3 安装位置,点击安装。
?
第4步添加环境变量
我把软件安装在d盘,故需要把以下路径添加到系统变量中,参照自己的安装位置,找到如下所示的路径。
D:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin
?
第5步:重启,进入anaconda 中的rasa环境
执行以下命名:
pip install dlib -i https://pypi.douban.com/simple
具体为:
(d:\Anaconda3) C:\Users\xxxx>activate rasaEnv
(rasaEnv) C:\Users\xxxx>pip install dlib -i https://pypi.douban.com/simple
该过程没有显示进度,时间过长。完成后如下图所示:
?
3 安装Mitie
3.1 在线安装mitie(不建议)
pip install git+git://github.com/mit-nlp/MITIE.git
pip install rasa[mitie] # 注:由于第一步始终没成功过,没尝试过这个命令的意义
在安装mite时容易出现错误,我在安装过程中出现了以下错误
ERROR: Command errored out with exit status 1:
'd:\anaconda3\envs\rasaEnv\python.exe'
-u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\yangwei\\AppData\\Local\\Temp\\pip-req-build-sgnk4ea2\\setup.py'"'"'; __file__='"'"'C:\\Users\\yangwei\\AppData\\Local\\Temp\\pip-req-build-sgnk4ea2\\setup.py'"'"';
f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');
code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');
f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\yangwei\AppData\Local\Temp\pip-record-xistd_ix\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\anaconda3\envs\rasaEnv\Include\mitie' Check the logs for full command output.
3.2 离线安装mitie
第一步:下载mite源码
mite地址:mirrors / mit-nlp / MITIE · GitCode
第二步:安装
解压mite源码文件到任意目录,这里我把mite解压文件放在了和rasaEnv的同目录下,方便管理。
进入mite目录位置,依次执行命令:
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6">python setup.py build
python setup.py install</span></span>
注意:jieba、rasa_core、rasa_nlu等即可以安装需求分别安装,但这样比较麻烦,建议直接跳过4、5、6。rasa提供了一次性安装的命令,具体为步骤7,在步骤7里,将会用一条命令将这个依赖的库,一次性安装,描述jieba、rasa_core、rasa_nlu等安装过程,只是保证文档完整性。
4 、安装jieba
?
pip install jieba -i Simple Index --trusted-host pypi.douban.com
?
5 、安装Rasa Core
推荐的安装Rasa Core的方法是使用pip:
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6">pip install rasa_core</span></span>
要是出现报错
?
则换个镜像
解决措施:
pip install rasa_core -i https://pypi.douban.com/simple
6、安装rasa_nlu
我们使用Rasa NLU进行意图分类和实体提取。为了得到它,运行
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6">pip install rasa_nlu -i https://pypi.douban.com/simple</span></span>
7、一次性安装所依赖的所有库
对于某些机器学习算法,您需要安装额外的 python 包。 默认情况下不安装它们以保持占用空间小。 Tuning Your Model 页面将帮助您为助手选择正确的配置,并提醒您注意其他依赖项。
你要是不介意下载更多的库,可以使用下面命名一次性安装所有的rasa依赖库。
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6">pip install rasa[full] -i https://pypi.douban.com/simple</span></span>
如图所示先切换到rasa环境中,再执行命令。
?
<span style="background-color:var(--code-block-bg-color)"><span style="color:#a9b7c6">ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
rasa-nlu 0.15.1 requires cloudpickle~=0.6.1, but you have cloudpickle 1.6.0 which is incompatible.
rasa-nlu 0.15.1 requires jsonschema~=2.6, but you have jsonschema 3.2.0 which is incompatible.
rasa-nlu 0.15.1 requires matplotlib~=2.2, but you have matplotlib 3.3.4 which is incompatible.
rasa-nlu 0.15.1 requires packaging~=18.0, but you have packaging 20.9 which is incompatible.
rasa-nlu 0.15.1 requires ruamel.yaml~=0.15.7, but you have ruamel-yaml 0.16.13 which is incompatible.
rasa-nlu 0.15.1 requires scikit-learn~=0.20.2, but you have scikit-learn 0.24.2 which is incompatible.
rasa-core 0.14.5 requires fbmessenger~=5.0, but you have fbmessenger 6.0.0 which is incompatible.
rasa-core 0.14.5 requires jsonschema~=2.6, but you have jsonschema 3.2.0 which is incompatible.
rasa-core 0.14.5 requires packaging~=18.0, but you have packaging 20.9 which is incompatible.
rasa-core 0.14.5 requires python-socketio~=3.0, but you have python-socketio 5.5.2 which is incompatible.
rasa-core 0.14.5 requires pytz~=2018.9, but you have pytz 2021.3 which is incompatible.
rasa-core 0.14.5 requires redis~=2.0, but you have redis 3.5.3 which is incompatible.
rasa-core 0.14.5 requires ruamel.yaml~=0.15.0, but you have ruamel-yaml 0.16.13 which is incompatible.
rasa-core 0.14.5 requires scikit-learn~=0.20.0, but you have scikit-learn 0.24.2 which is incompatible.
rasa-core 0.14.5 requires slackclient~=1.0, but you have slackclient 2.9.3 which is incompatible.
rasa-core 0.14.5 requires tensorflow~=1.13.0, but you have tensorflow 2.6.1 which is incompatible.</span></span>
要是出现以上错误提示,则升级rasa,
pip3 install --upgrade rasa
再执行
pip install rasa[full] -i https://pypi.douban.com/simple
8 anaconda+pycharm配置:
新建一个工程,选择python环境,如下图所示。
?
?
工程文件建立完成后,即可查看rasa版本:
9、创建经典案例
打开prcharm Terminal 输入命令rasa init,使用示例训练数据为你建立一个完整的项目。
rasa init
执行过程中,会自动创建项目所需的文件目录:
?
然后按照提示,输入“y”,继续执行即可,完成后,输入对话内容:
?
|