There are basically 3 tips I have for debugging import issues:
- Use the interactive interpreter (The REPL) to import the modules and see if you are getting what you expect.
- Start your script with
python -v -m my_scriptname.pyand then check the output to see exactly where your modules are getting imported from. (-m represents modular initialization)
- Use Pycharm. Pycharm’s fantastic introspection abilities mean that you will immeadiately know whether or not your module is being properly imported as it will indicate an error if not. It will sometimes also suggest the proper correction.
Note: The community edition is free and if you’re a student you can get a free subscription to ALL of their products!