首页 > 解决方案 > FileNotFoundError: [Errno 2] No such file or directory: (using import OS)

问题描述

I looked around for solutions. One of them is to use os.path, but I still get an error. I'm trying to send an image to a discord server channel when the bot is up and running here is the documentation. But I get an error FileNotFoundError: [Errno 2] No such file or directory:

Attached are some screenshots of my project, code, & error message.enter image description here

enter image description here

enter image description here

标签: pythonpython-3.xdiscord.py

解决方案


路径似乎并不完整。dog.png 在 src 文件夹中,所以不要使用 is,只需自己指定目录BASE_DIR = '.\Pickle Rick BOT\src'。然后您可以使用 os.path.join 或 f 流的简单字符串连接将dog.png部分加入到此。反斜杠应该加倍。


推荐阅读