本文最后更新于:2023年12月15日 晚上
前言
本文开始介绍如何配置编程环境 关于gocq
和python
安装
可以看第零篇
安装Vscode
打开官网Vsocode
点击下面的download按钮
等待下载完成…
双击打开安装包 按照提示进行下一步的安装
大概页面如下
在vscode里配置python
点击正方体的按钮 单击搜索框
输入python
进行安装
tips:我这里已经安装了 这里应该要点install按钮
在你的桌面上创建一个py文件 用vscode打开试一下
如果有自动补全 说明已经成功了
这个时候可以挂起来vscode了
下载Nonebot2
点你左上角的Windows 右键打开powershelladmin
的
按如下输入
1 2 3 4 5
| pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple pip install nb-cli pip install nonebot2 nb driver install nonebot2[fastapi] nb adapter install nonebot-adapter-onebot
|
恭喜你 nb已经安装到你电脑上了
如果在下方安装出错 可以联系作者
创建Nonebot2项目
这个时候切记不要关闭你的powershell
输入一句nb
然后回车
选择创建项目
回车
上下选择 回车确认 选择开发者
输入名字,回车
注意:上下切换选项目 空格选择 回车确认 一定要记住
选择fastapi
选择onebot v11
协议
选择在scr
目录下
接下来 选择echo插件
回车
大功告成
运行Nonebot2
先打开你的gocq 此处省略
vscode点右上角的终端
请确保是在该目录下的文件夹
那如何进入文件夹和退出文件夹?
在终端输入nb run
如果成功会出现
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| 06-29 00:33:29 [SUCCESS] nonebot | NoneBot is initializing... 06-29 00:33:29 [INFO] nonebot | Current Env: dev 06-29 00:33:29 [SUCCESS] nonebot | Succeeded to load plugin "admin" from "plugins.admin" 06-29 00:33:29 [ERROR] config | 当前未配置用户名和密码,请到admin.py配置!!! 06-29 00:33:30 [SUCCESS] nonebot | Succeeded to load plugin "group_1" from "plugins.group_1" 06-29 00:33:30 [SUCCESS] trun_on | 兽云nonebot2 插件启动成功 06-29 00:33:30 [SUCCESS] trun_on | 当前版本为0.1 正式版 06-29 00:33:30 [SUCCESS] trun_on | 如有问题可以来https://github.com/bingqiu456/shouyun 来反馈 06-29 00:33:30 [WARNING] trun_on | 正在检查更新,请勿退出 06-29 00:33:31 [WARNING] trun_on | 检测到新版本:1.1 更新日志 2023-06-17 本次更新内容较多,可能比较费时间 1.新增心跳开关(config.py) 2.修复了群开关无反应 3.修复了登录验证码bug 06-29 00:33:31 [SUCCESS] trun_on | ╰(*°▽*)╯ 祝你使用愉快 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "trun_on" from "plugins.trun_on" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "yiyan" from "plugins.yiyan" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "login_token" from "plugins.login_token" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "image_random" from "plugins.image_random" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "reboot" from "plugins.reboot" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "logo_acct" from "plugins.logo_acct" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "image_download" from "plugins.image_download" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "image_check" from "plugins.image_check" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "about" from "plugins.about" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "config" from "plugins.config" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "accot" from "plugins.accot" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "login" from "plugins.login" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "image_updata" from "plugins.image_updata" 06-29 00:33:31 [SUCCESS] nonebot | Succeeded to load plugin "lingp" from "plugins.lingp" 06-29 00:33:32 [SUCCESS] xint | 心跳包未开启 06-29 00:33:32 [SUCCESS] nonebot | Succeeded to load plugin "xint" from "plugins.xint" 06-29 00:33:32 [SUCCESS] nonebot | Succeeded to load plugin "menu" from "plugins.menu" 06-29 00:33:32 [SUCCESS] nonebot | Running NoneBot... 06-29 00:33:33 [INFO] uvicorn | Started server process [2976] 06-29 00:33:33 [INFO] uvicorn | Waiting for application startup. 06-29 00:33:33 [INFO] nonebot_plugin_apscheduler | Scheduler Started 06-29 00:33:33 [INFO] uvicorn | Application startup complete. 06-29 00:33:33 [INFO] uvicorn | Uvicorn running on http://0.0.0.0:20000 (Press CTRL+C to quit)
|
出现06-29 00:33:33 [INFO] uvicorn | Uvicorn running on http://0.0.0.0:20000 (Press CTRL+C to quit)
代表nb启动成功
ModuleNotFoundError: No module named ‘nonebot’
这说明你的nb2没有安装成功
通常每个套 接字地址(协议/网络地址/端口)只允许使用一次。
这说明你的端口发生冲突 检查你是不是重复启动nb 或者有其他项目占用了该端口号
后记
下一期 我们来编写一个 随机人生
吧