我正在开发一个 Discord 机器人,它将一些数据保存到 mongodb 数据库以响应一些用户命令。奇怪的是它可以在 repl.it 上运行,但我在 SparkedHost 上收到此错误。当我创建新的 MongoClient 对象时,出现奇怪的错误。服务器安装了Python3 3.6.15。回溯看起来像这样:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.6/site-packages/discord/ext/commands/core.py",
line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/container/main.py", line 36, in listMyWants
await botcommandscontroller.listWants(ctx, ctx.author.id)
File "/home/container/botcommandscontroller.py", line 10, in listWants
wants = mongodbcontroller.getWants(targetID)
File "/home/container/mongodbcontroller.py", line 17, in getWants
cluster = MongoClient(os.getenv('MONGOCONNECT'))
File "/home/container/.local/lib/python3.6/site-packages/pymongo/mongo_client.py", line
712, in __init__
srv_max_hosts=srv_max_hosts,
File "/home/container/.local/lib/python3.6/site-packages/pymongo/uri_parser.py", line
467, in parse_uri
python_path = sys.executable or "python"
NameError: name 'sys' is not defined
Run Code Online (Sandbox Code Playgroud)
这是我的 …