<jupyter_start><jupyter_text>Check that libraries are installedThis notebook checks to see if you have the correct version of Python as well as all necessary libraries installed.Check the [main README file](https://github.com/anthony-wang/BestPractices/blob/master/README.md) for instructions if anything is missing.<jupyter_code>from __future__ import print_function
from distutils.version import LooseVersion as Version
import sys

try:
    import curses
    curses.setupterm()
    assert curses.tigetnum("colors") > 2
    OK = "\x1b[1;%dm[ OK ]\x1b[0m" % (30 + curses.COLOR_GREEN)
    FAIL = "\x1b[1;%dm[FAIL]\x1b[0m" % (30 + curses.COLOR_RED)
except:
    OK = '[ OK ]'
    FAIL = '[FAIL]'

try:
    import importlib
except ImportError:
    print(FAIL, "Python version 3.4 is required,"
                " but %s is installed." % sys.version)

def import_version(pkg, min_ver):
    mod = None
    try:
        mod = importlib.import_module(pkg)
        if pkg in {'PIL'}:
            ver = mod.VERSION
        else:
            ver = mod.__version__
        if Version(ver) < min_ver:
            print(FAIL, "%s version %s or higher required, but %s installed."
                  % (lib, min_ver, ver))
        else:
            print(OK, '%s version %s' % (pkg, ver))
    except ImportError as imp_err_msg:
        print(FAIL, 'Error in importing %s: %s' % (pkg, imp_err_msg))
    except AttributeError as att_err_msg:
        print(FAIL, 'Error in reading attribute of %s: %s' % (pkg, att_err_msg))
    return mod

# first check the python version
print('Using python in', sys.prefix)
print(sys.version)
pyversion = Version(sys.version)
if pyversion >= "3":
    if pyversion < "3.7":
        print(FAIL, "Python version > 3.7 is required,"
                    " but %s is installed.\n" % sys.version)
elif pyversion < "3":
    print(FAIL, "Python version > 3.7 is required,"
                " but %s is installed.\n" % sys.version)
else:
    print(FAIL, "Unknown Python version: %s\n" % sys.version)

requirements = {'numpy': '1.18.0',
                'pandas': '1.0.0',
                'pandas_profiling': '2.4.0',
                'matplotlib': '3.2.0',
                'seaborn': '0.10.0',
                'sklearn': '0.22.0',
                'scipy': '1.4.0',
                'tqdm': '4.43.0',
                'jupyter_client': '6.0.0',
                'ipywidgets': '7.5.0',
                'torch': '1.3.0',}

# now check the dependencies
for lib, required_version in list(requirements.items()):
    import_version(lib, required_version)<jupyter_output>Using python in C:\Users\Anthony\Anaconda3\envs\bestpractices
3.7.6 | packaged by conda-forge | (default, Mar  5 2020, 14:47:50) [MSC v.1916 64 bit (AMD64)]
[ OK ] numpy version 1.18.1
[ OK ] pandas version 1.0.2
[ OK ] pandas_profiling version 2.4.0
[ OK ] matplotlib version 3.2.0
[ OK ] seaborn version 0.10.0
[ OK ] sklearn version 0.22.2.post1
[ OK ] scipy version 1.4.1
[ OK ] tqdm version 4.43.0
[ OK ] jupyter_client version 6.1.2
[ OK ] ipywidgets version 7.5.1
[ OK ] torch version 1.3.1
{'fraction_non_alphanumeric': 0.13366013071895425, 'fraction_numerical': 0.03954248366013072, 'mean_word_length': 2.502288329519451, 'pattern_counts': {'":': 3, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '296609', 'license': 'MIT', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1041, 'n_words': 296, 'path': 'notebooks/0b-check_dependencies.ipynb', 'repo_name': 'stefanbringuier/BestPractices', 'size': '3060'}