2

So I am trying to import certain packages, when I use this command in cmd, py test.py, all I get is ModuleNotFoundError: No module named holidays

The only thing in test.py is import holidays.

But when I try to execute test.py in sublime text3, it works. No error happens.

I have tried to find the answer by Google, but can's find anything helpful. Please help me. Thank you all!

Mars Lee
  • 1,845
  • 5
  • 17
  • 37

1 Answers1

0

I think it may be linked to what @wim say in this post

You may want to check some points:

  1. Do you use the same python interpreter?

    import sys; print(sys.executable)

  2. Is this the same current directory that both use?

    import os; print(os.getcwd())

  3. Check the sys.path, and difference between both could lead to error (can be caused by environment variable).

    import sys; print(sys.path)

(This answer is totally based on what Wim said and was accepted on the question from the linked post, if it answer your question please give him credit).

Eric Godard
  • 179
  • 12