This file is indexed.

/usr/lib/python2.7/dist-packages/jupyter_core/troubleshoot.py is in python-jupyter-core 4.4.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#!/usr/bin/env python
"""
display environment information that isfrequently
used to troubleshoot installations of Jupyter or IPython
"""

# import argparse
import os
import platform
import subprocess
import sys


# def get_args():
#     """
#     TODO: output in JSON or xml? maybe?
#     """
#     pass

def subs(cmd):
    """
    get data from commands that we need to run outside of python
    """
    try:
        stdout = subprocess.check_output(cmd)
        return stdout.decode('utf-8', 'replace').strip()
    except (OSError, subprocess.CalledProcessError):
        return None


def get_data():
    """
    returns a dict of various user environment data
    """
    env = {}
    env['path'] = os.environ.get('PATH')
    env['sys_path'] = sys.path
    env['sys_exe'] = sys.executable
    env['sys_version'] = sys.version
    env['platform'] = platform.platform()
    # FIXME: which on Windows?
    if sys.platform == 'win32':
        env['where'] = subs(['where', 'jupyter'])
        env['which'] = None
    else:
        env['which'] = subs(['which', '-a', 'jupyter'])
        env['where'] = None
    env['pip'] = subs([sys.executable, '-m', 'pip', 'list'])
    env['conda'] = subs(['conda', 'list'])
    return env


def main():
    """
    print out useful info
    """
    #pylint: disable=superfluous-parens
    # args = get_args()
    environment_data = get_data()

    print('$PATH:')
    for directory in environment_data['path'].split(os.pathsep):
        print('\t' + directory)

    print('\n' + 'sys.path:')
    for directory in environment_data['sys_path']:
        print('\t' + directory)

    print('\n' + 'sys.executable:')
    print('\t' + environment_data['sys_exe'])

    print('\n' + 'sys.version:')
    if '\n' in environment_data['sys_version']:
        for data in environment_data['sys_version'].split('\n'):
            print('\t' + data)
    else:
        print('\t' + environment_data['sys_version'])

    print('\n' + 'platform.platform():')
    print('\t' + environment_data['platform'])

    if environment_data['which']:
        print('\n' + 'which -a jupyter:')
        for line in environment_data['which'].split('\n'):
            print('\t' + line)

    if environment_data['where']:
        print('\n' + 'where jupyter:')
        for line in environment_data['where'].split('\n'):
            print('\t' + line)

    if environment_data['pip']:
        print('\n' + 'pip list:')
        for package in environment_data['pip'].split('\n'):
            print('\t' + package)

    if environment_data['conda']:
        print('\n' + 'conda list:')
        for package in environment_data['conda'].split('\n'):
            print('\t' + package)


if __name__ == '__main__':
    main()