Are you running the script in the same environment?
You would usually see this kind of error, if your current Python env does not contain the installed libs (often a mismatch of the used Jupyter Python kernel vs. your terminal).