Script running in PyCharm but not from the command line

There are a few possible things that can be causing this:

  1. The same python interpreter? Check with import sys; print(sys.executable)
  2. Is it the same working directory? Check with import os; print(os.getcwd())
  3. Discrepancies in sys.path, which is the list python searches sequentially for import locations, can possibly caused by environment variables. Check with import sys; print(sys.path).

Leave a Comment