It's useful to look at the stack trace itself. The only way your script can fail like that is if the call to twitter is failing. In this case, the only thing that could reasonably differ with the batch file versus the interactive command line is somehow the bearer token is different. Since bearer tokens often have percent symbols in them, there's probably something going on there.
We can simplify this with a simple script:
# This is example.py
import os
print("BEARER_TOKEN=[" + os.environ.get("BEARER_TOKEN") + "]")
If you run this interactively, it works as you'd expect:
C:Example>set BEARER_TOKEN=this%is%an%example%token
C:Example>python example.py
BEARER_TOKEN=[this%is%an%example%token]
However, running it with a simple batch file, it will not work as expected:
@echo off
rem This is example.cmd
set BEARER_TOKEN=this%is%an%example%token
python3 example.py
C:Example>example.cmd
BEARER_TOKEN=[thisantoken]
You'll need to escape the percent symbols in your batch file, since they're parsed differently than the interactive prompt:
@echo off
rem This is the fixed example.cmd
set BEARER_TOKEN=this%%is%%an%%example%%token
python3 example.py
C:Example>example.cmd
BEARER_TOKEN=[this%is%an%example%token]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…