Tips to Debug the import Issues in python

There are basically 3 tips I have for debugging import issues:

  1. Use the interactive interpreter (The REPL) to import the modules and see if you are getting what you expect.
  2. Start your script with python -v -m my_scriptname.py and then check the output to see exactly where your modules are getting imported from. (-m represents modular initialization)
  3. 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!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s