How can I check if a module/library/package is part of the python standard library?
06:06 05 Mar 2014

I have installed sooo many libraries/modules/packages with pip and now I cannot differentiate which are native to the Python standard library and which are not. This causes problem when my code works on my machine, but it doesn't work anywhere else.

How can I check if a module/library/package that I import in my code is from the Python standard library?

Assume that the checking is done on the machine with all the external libraries/modules/packages. Otherwise, I could simply do a try-except import on the other machine that doesn't have them.

For example, I am sure these imports work on my machine, but when it's on a machine with only a plain Python install, it breaks:

from bs4 import BeautifulSoup
import nltk
import PIL
import gensim
python module package native