簡體   English   中英

無法從“身份驗證”導入名稱“bot_token”

[英]cannot import name 'bot_token' from 'authentication'

嗨,我在使用這個 python 腳本時遇到了問題 這是錯誤

PS C:\Users\betha\Downloads\Ghost-chan-main> & C:/Users/betha/AppData/Local/Microsoft/WindowsApps/python3.9.exe c:/Users/betha/Downloads/Ghost-chan-main/Ghost-chan-main/main.py
Traceback (most recent call last):
  File "c:\Users\betha\Downloads\Ghost-chan-main\Ghost-chan-main\main.py", line 6, in <module>
    from authentication import bot_token
ImportError: cannot import name 'bot_token' from 'authentication' (C:\Users\betha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\authentication\__init__.py)
PS C:\Users\betha\Downloads\Ghost-chan-main> 

這是 GitHub: https://github.com/vichannnnn/Ghost-chan我正在嘗試為我的朋友設置這個機器人

我認為問題是缺少帶有代碼的文件authentication.py

bot_token = your_token

作者沒有添加這個,因為他/她的令牌不應該被共享。

因為沒有authentication.py所以import找到了一些名稱為authentication的模塊,它試圖從這個模塊中獲取bot_token - 但這個模塊不能擁有它,因為它不是為此創建的。

你有兩個解決方案:

  1. 在帶有項目的文件夾中使用代碼bot_token = your_token創建文件authentication.py

  2. 刪除線

    from authentication import bot_token

    放線

    bot_token = your_token

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM