-
Notifications
You must be signed in to change notification settings - Fork 227
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
[提问] 获取动态示例错误 #681
Comments
您 |
不不,我描述有问题,问题是;程序运行1分钟没有输出,无响应 2024-02-13.22-34-48.mp4 |
虽然但是,建议使用 vscode 等编辑器来调试程序 |
:( 感谢你的回复 PS C:\Users\NAS\BilibiliGetDynamics> & 'c:\Users\NAS\AppData\Local\Programs\Python\Python38\python.exe' 'c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '8225' '--' 'C:\Users\NAS\BilibiliGetDynamics\1.py'
E+00000.093: Error while enumerating installed packages.
Traceback (most recent call last):
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\common\log.py", line 361, in get_environment_description
report(" {0}=={1}\n", pkg.name, pkg.version)
AttributeError: 'PathDistribution' object has no attribute 'name'
Stack where logged:
File "C:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher\__main__.py", line 91, in <module>
main()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher\__main__.py", line 21, in main
log.describe_environment("debugpy.launcher startup environment:")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\common\log.py", line 369, in describe_environment
info("{0}", get_environment_description(header))
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\common\log.py", line 363, in get_environment_description
swallow_exception("Error while enumerating installed packages.")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\common\log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs)
E+00000.031: Error while enumerating installed packages.
Traceback (most recent call last):
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 361, in get_environment_description
report(" {0}=={1}\n", pkg.name, pkg.version)
AttributeError: 'PathDistribution' object has no attribute 'name'
Stack where logged:
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
cli.main()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 415, in main
api.ensure_logging()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\api.py", line 61, in ensure_logging
log.describe_environment("Initial environment:")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 369, in describe_environment
info("{0}", get_environment_description(header))
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 363, in get_environment_description
swallow_exception("Error while enumerating installed packages.")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs)
E+00000.235: Error while enumerating installed packages.
Traceback (most recent call last):
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 361, in get_environment_description
report(" {0}=={1}\n", pkg.name, pkg.version)
AttributeError: 'PathDistribution' object has no attribute 'name'
Stack where logged:
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
cli.main()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 281, in run_file
log.describe_environment("Pre-launch environment:")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 369, in describe_environment
info("{0}", get_environment_description(header))
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 363, in get_environment_description
swallow_exception("Error while enumerating installed packages.")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs) 手动 Traceback (most recent call last):
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
cli.main()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "C:\Users\NAS\BilibiliGetDynamics\1.py", line 34, in <module>
sync(main())
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\site-packages\bilibili_api\utils\sync.py", line 33, in sync
return loop.run_until_complete(coroutine)
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 603, in run_until_complete
self.run_forever()
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 570, in run_forever
self._run_once()
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1823, in _run_once
event_list = self._selector.select(timeout)
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\selectors.py", line 323, in select
r, w, _ = self._select(self._readers, self._writers, [], timeout)
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\selectors.py", line 314, in _select
r, w, x = select.select(r, w, w, timeout)
KeyboardInterrupt |
这问题貌似与模块无关,因为问题出在 |
不使用 |
或者安装 |
:( 感谢你的回复 PS C:\Users\NAS\BilibiliGetDynamics> c:; cd 'c:\Users\NAS\BilibiliGetDynamics'; & 'c:\Users\NAS\AppData\Local\Programs\Python\Python38\python.exe' 'c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '13084' '--' 'C:\Users\NAS\BilibiliGetDynamics\1.py'
Traceback (most recent call last):
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
cli.main()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\Users\NAS\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "C:\Users\NAS\BilibiliGetDynamics\1.py", line 34, in <module>
sync(main())
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\site-packages\bilibili_api\utils\sync.py", line 33, in sync
return loop.run_until_complete(coroutine)
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 603, in run_until_complete
self.run_forever()
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 570, in run_forever
self._run_once()
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1823, in _run_once
event_list = self._selector.select(timeout)
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\selectors.py", line 323, in select
r, w, _ = self._select(self._readers, self._writers, [], timeout)
File "c:\Users\NAS\AppData\Local\Programs\Python\Python38\lib\selectors.py", line 314, in _select
r, w, x = select.select(r, w, w, timeout)
KeyboardInterrupt 2024-02-15.02-03-52.mp4 |
发下程序 |
好抽象…我一直没电脑,干盯着,最顶上那份示例真的能跑吗?不会一直 while True 吧?
|
程序: 1.zip |
我无语了...老哥你是不会打断点的吗?看看返回值啊 以及B站脑瘫设计 import json
from bilibili_api import user, sync
# 实例化
u = user.User(660303135)
async def main():
# 用于记录下一次起点
offset = 0
# 用于存储所有动态
dynamics = []
# 无限循环,直到 has_more != 1
while True:
# 获取该页动态
page = await u.get_dynamics(offset)
if "cards" in page:
# 若存在 cards 字段(即动态数据),则将该字段列表扩展到 dynamics
dynamics.extend(page["cards"])
else:
break
if page["has_more"] != 1:
# 如果没有更多动态,跳出循环
break
# 设置 offset,用于下一轮循环
offset = page["next_offset"]
# 打印动态数量
print(f"共有 {len(dynamics)} 条动态")
# 入口
sync(main()) |
Python 版本: 3.8
模块版本: 16.2.0 Name: bilibili-api-python
运行环境: Windows
Google,issue没找到解决方法
报错
运行代码
debug
The text was updated successfully, but these errors were encountered: