Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[教程]如何部署在腾讯云函数 #3

Closed
zhongfly opened this issue Jun 1, 2021 · 25 comments
Closed

[教程]如何部署在腾讯云函数 #3

zhongfly opened this issue Jun 1, 2021 · 25 comments

Comments

@zhongfly
Copy link
Contributor

zhongfly commented Jun 1, 2021

image

我不“瞎BB”了

@zhongfly zhongfly changed the title 如何部署在腾讯云函数 [教程]如何部署在腾讯云函数 Jun 1, 2021
@zhongfly
Copy link
Contributor Author

zhongfly commented Jun 1, 2021

使用的telegram推送的注意,腾讯云不提供代理的,建议使用相关反代。
例如使用 https://github.com/Zibri/cloudflare-cors-anywhere 借助cloudflare worker进行反代,推送地址填写 https://你的cloudflare worker地址/?https://api.telegram.org/bot{telegram_bot_token}/sendMessage

@daoyunsd
Copy link

daoyunsd commented Jun 4, 2021

START RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6

ERROR RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6 Result:{"errorCode":-1,"errorMessage":"Traceback (most recent call last):\n File "/var/runtime/python3/bootstrap.py", line 133, in init_handler\n func_handler = get_func_handler(file.rsplit(".", 1)[0], func)\n File "/var/runtime/python3/bootstrap.py", line 159, in get_func_handler\n mod = imp.load_module(mname, *imp.find_module(mname))\n File "/var/lang/python3/lib/python3.6/imp.py", line 234, in load_module\n return load_source(name, filename, file)\n File "/var/lang/python3/lib/python3.6/imp.py", line 172, in load_source\n module = _load(spec)\n File "\u003cfrozen importlib._bootstrap\u003e", line 675, in _load\n File "\u003cfrozen importlib._bootstrap\u003e", line 655, in _load_unlocked\n File "\u003cfrozen importlib._bootstrap_external\u003e", line 678, in exec_module\n File "\u003cfrozen importlib._bootstrap\u003e", line 205, in _call_with_frames_removed\n File "/var/user/BiliExp.py", line 7, in \u003cmodule\u003e\n from BiliClient import asyncbili\n File "/var/user/BiliClient/init.py", line 12, in \u003cmodule\u003e\n from .asyncBiliApi import asyncBiliApi as asyncbili #B站接口模块,由aiohttp模块实现异步http请求\n File "/var/user/BiliClient/asyncBiliApi.py", line 2, in \u003cmodule\u003e\n from aiohttp import ClientSession\nModuleNotFoundError: No module named 'aiohttp'","statusCode":443}

END RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6

Report RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6 Duration:0ms Memory:128MB MemUsage:0.000000MB

@daoyunsd
Copy link

daoyunsd commented Jun 4, 2021

请问这是什么情况啊

@zhongfly
Copy link
Contributor Author

zhongfly commented Jun 5, 2021

START RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6

ERROR RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6 Result:{"errorCode":-1,"errorMessage":"Traceback (most recent call last):\n File "/var/runtime/python3/bootstrap.py", line 133, in init_handler\n func_handler = get_func_handler(file.rsplit(".", 1)[0], func)\n File "/var/runtime/python3/bootstrap.py", line 159, in get_func_handler\n mod = imp.load_module(mname, *imp.find_module(mname))\n File "/var/lang/python3/lib/python3.6/imp.py", line 234, in load_module\n return load_source(name, filename, file)\n File "/var/lang/python3/lib/python3.6/imp.py", line 172, in load_source\n module = _load(spec)\n File "\u003cfrozen importlib._bootstrap\u003e", line 675, in _load\n File "\u003cfrozen importlib._bootstrap\u003e", line 655, in _load_unlocked\n File "\u003cfrozen importlib._bootstrap_external\u003e", line 678, in exec_module\n File "\u003cfrozen importlib._bootstrap\u003e", line 205, in _call_with_frames_removed\n File "/var/user/BiliExp.py", line 7, in \u003cmodule\u003e\n from BiliClient import asyncbili\n File "/var/user/BiliClient/init.py", line 12, in \u003cmodule\u003e\n from .asyncBiliApi import asyncBiliApi as asyncbili #B站接口模块,由aiohttp模块实现异步http请求\n File "/var/user/BiliClient/asyncBiliApi.py", line 2, in \u003cmodule\u003e\n from aiohttp import ClientSession\nModuleNotFoundError: No module named 'aiohttp'","statusCode":443}

END RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6

Report RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6 Duration:0ms Memory:128MB MemUsage:0.000000MB

没做第7步……别擅自发挥了

@daoyunsd
Copy link

daoyunsd commented Jun 5, 2021

好的谢谢 但是我第七步命令做了的

@zhongfly
Copy link
Contributor Author

zhongfly commented Jun 5, 2021

好的谢谢 但是我第七步命令做了的

我补充了一张图片在步骤内,完成后大致是那样的,你肯定是缺少了/报错了,建议再试一次
在serverless文件夹内:
pip3 install -r requirements.txt -t ./

@zhongfly zhongfly mentioned this issue Jun 5, 2021
@daoyunsd
Copy link

daoyunsd commented Jun 5, 2021

感谢大佬 我用懒人包成功 谢谢 谢谢

@daoyunsd
Copy link

daoyunsd commented Jun 5, 2021

请问一下大佬 这个云函数里面怎么设置才能自动转发抽奖,我好友动态里面有很多抽奖的。我运行云函数日志总是显示调用失败而且没有推送。万分感谢

@zhongfly
Copy link
Contributor Author

zhongfly commented Jun 7, 2021

请问一下大佬 这个云函数里面怎么设置才能自动转发抽奖,我好友动态里面有很多抽奖的。我运行云函数日志总是显示调用失败而且没有推送。万分感谢

应该是代码问题,我不清楚。

@zhongfly
Copy link
Contributor Author

请问大佬懒人包没有头文件怎么上传代码呢,这个仓库不能action啊

你是真的看了教程后实践过发现不能才来问的吗?

@daoyunsd
Copy link

daoyunsd commented Jun 14, 2021 via email

@zhongfly
Copy link
Contributor Author

zhongfly commented Jun 14, 2021

添加了腾讯云id和key后去action只显示Get started with GitHub Actions
Build, test, and deploy your code. Make code reviews, branch management, and issue triaging work the way you want. Select a workflow template to get started.

Skip this and set up a workflow yourself

你完全没看我写的这个教程,那就不应该来问我为什么不能。
结果又来问该怎么做?不是写在这里吗?能好好看了再提问吗…

@YYplus
Copy link

YYplus commented Aug 3, 2021

可以抽空更新一下懒人包吗,麻烦了

@zhongfly
Copy link
Contributor Author

zhongfly commented Aug 3, 2021

可以抽空更新一下懒人包吗,麻烦了

已更新,其实你自己下载这个项目,然后覆盖就行了……

@YYplus
Copy link

YYplus commented Aug 4, 2021

可以抽空更新一下懒人包吗,麻烦了

已更新,其实你自己下载这个项目,然后覆盖就行了……

谢谢,麻烦了

@YYplus
Copy link

YYplus commented Aug 4, 2021

新版懒人包报错
image

@zhongfly
Copy link
Contributor Author

zhongfly commented Aug 5, 2021

新版懒人包报错
image

与我无关,项目最新版就是这样

@YYplus
Copy link

YYplus commented Aug 5, 2021

新版懒人包报错
image

与我无关,项目最新版就是这样

好的,谢谢

@zhongfly
Copy link
Contributor Author

zhongfly commented Aug 5, 2021

新版懒人包报错
image

我已经修复了,应该没问题

@YYplus
Copy link

YYplus commented Aug 6, 2021

新版懒人包报错
image

我已经修复了,应该没问题

还是不能正常运行START RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f

ERROR RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f Result:{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"Traceback (most recent call last):\nTypeError: main() takes 1 positional argument but 2 were given","statusCode":430}

END RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f

Report RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f Duration:1ms Memory:128MB MemUsage:25.882812MB

@zhongfly
Copy link
Contributor Author

zhongfly commented Aug 6, 2021

还是不能正常运行START RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f

ERROR RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f Result:{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"Traceback (most recent call last):\nTypeError: main() takes 1 positional argument but 2 were given","statusCode":430}

END RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f

Report RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f Duration:1ms Memory:128MB MemUsage:25.882812MB

代码没有问题,请自查问题。
现在的修改对云函数运行有影响,还不如不更新呢
试着修好了,云函数上能运行了

@YYplus
Copy link

YYplus commented Aug 6, 2021

还是不能正常运行START RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f
ERROR RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f Result:{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"Traceback (most recent call last):\nTypeError: main() takes 1 positional argument but 2 were given","statusCode":430}
END RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f
Report RequestId:395eadd3-2125-4149-97bc-f27e5fa0d36f Duration:1ms Memory:128MB MemUsage:25.882812MB

代码没有问题,请自查问题。
现在的修改对云函数运行有影响,还不如不更新呢
试着修好了,云函数上能运行了

真是艰难阿,麻烦大佬了,再次表示感谢

@miachannel1
Copy link

Snipaste_2021-10-05_00-09-18
到第十步出现这个错误是怎么回事呀

@zhongfly
Copy link
Contributor Author

zhongfly commented Oct 4, 2021

Snipaste_2021-10-05_00-09-18 到第十步出现这个错误是怎么回事呀

serverless文件里原有的4个文件需要删除aliyun_serverless.yml

要不就是你某步没按教程做,要在serverless文件夹里运行sls deploy

@wdssfff00
Copy link

成功了,记录下为什么报下面的错(日志找不到了借上面楼的错用下,报错时我看是一样的错)
大佬#40教程没毛病,主要是第八步(上传好之后先安装依赖,终端cd src然后pip3 install -r requirements.txt -t ./,这样的话依赖全和源码混在一起,有时间的可以试试腾讯云的层管理...依赖可能一次安装不成功,多试几次)
这一步的requirements.txt文件内容要换成云函数的requirements.txt内容,
具体操作是把src文件夹里的requirements.txt内容换成src/serverless里的requirements.txt内容,
即把src文件夹里的requirements.txt内容换成
aiohttp==3.7.4
idna_ssl==1.1.0
json5==0.9.5

换成上面这三行就行
之后再执行大佬第八步就成了

=====================================
START RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6

ERROR RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6 Result:{"errorCode":-1,"errorMessage":"Traceback (most recent call last):\n File "/var/runtime/python3/bootstrap.py", line 133, in init_handler\n func_handler = get_func_handler(file.rsplit(".", 1)[0], func)\n File "/var/runtime/python3/bootstrap.py", line 159, in get_func_handler\n mod = imp.load_module(mname, *imp.find_module(mname))\n File "/var/lang/python3/lib/python3.6/imp.py", line 234, in load_module\n return load_source(name, filename, file)\n File "/var/lang/python3/lib/python3.6/imp.py", line 172, in load_source\n module = _load(spec)\n File "\u003cfrozen importlib._bootstrap\u003e", line 675, in _load\n File "\u003cfrozen importlib._bootstrap\u003e", line 655, in _load_unlocked\n File "\u003cfrozen importlib._bootstrap_external\u003e", line 678, in exec_module\n File "\u003cfrozen importlib._bootstrap\u003e", line 205, in _call_with_frames_removed\n File "/var/user/BiliExp.py", line 7, in \u003cmodule\u003e\n from BiliClient import asyncbili\n File "/var/user/BiliClient/init.py", line 12, in \u003cmodule\u003e\n from .asyncBiliApi import asyncBiliApi as asyncbili #B站接口模块,由aiohttp模块实现异步http请求\n File "/var/user/BiliClient/asyncBiliApi.py", line 2, in \u003cmodule\u003e\n from aiohttp import ClientSession\nModuleNotFoundError: No module named 'aiohttp'","statusCode":443}

END RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6

Report RequestId:4d1b76ee-2cf1-47b2-9eb2-9a33ec33d1c6 Duration:0ms Memory:128MB MemUsage:0.000000MB

=======================================================================

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants