我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用IPython.__version__()。
def _list_3rd_party(): from ..thirdparty import pyqtgraph import qtawesome try: from qtconsole import __version__ as qtconsole_version from IPython import __version__ as ipython_version except ImportError: qtconsole_version = 'N/A' ipython_version = 'N/A' return [ ('PyUAVCAN', uavcan.__version__, 'MIT', 'http://uavcan.org/Implementations/Pyuavcan'), ('PyQt5', PYQT_VERSION_STR, 'GPLv3', 'https://www.riverbankcomputing.com/software/pyqt/intro'), ('PyQtGraph', pyqtgraph.__version__, 'MIT', 'http://www.pyqtgraph.org/'), ('QtAwesome', qtawesome.__version__, 'MIT', 'https://github.com/spyder-ide/qtawesome'), ('QtConsole', qtconsole_version, 'BSD', 'http://jupyter.org'), ('IPython', ipython_version, 'BSD', 'https://ipython.org'), ]
def shell(): import IPython from flask.globals import _app_ctx_stack app = _app_ctx_stack.top.app banner = 'Python %s on %s\nIPython: %s\nApp: %s%s\nInstance: %s\n' % ( sys.version, sys.platform, IPython.__version__, app.import_name, app.debug and ' [debug]' or '', app.instance_path, ) ctx = {} startup = os.environ.get('PYTHONSTARTUP') if startup and os.path.isfile(startup): with open(startup, 'rb') as f: eval(compile(f.read(), startup, 'exec'), ctx) ctx.update(app.make_shell_context()) IPython.embed(banner1=banner, user_ns=ctx)
def init_inspector(self): super(RekallShell, self).init_inspector() # This is a hack but seems the only way to make get_ipython() work # properly. InteractiveShell._instance = self ipython_version = IPython.__version__ # IPython 5 (4 should work too) is the one we standardize on right # now. This means we support earlier ones but turn off the bells and # whistles. if "4.0.0" <= ipython_version < "6.0.0": self.inspector = RekallObjectInspector() else: self.user_ns.session.logging.warn( "Warning: IPython version %s not fully supported. " "We recommend installing IPython version 5.", ipython_version)
def is_ipython_versionorgreater(major, minor): """checks if we are at least a specific IPython version""" match = re.match('(\d+).(\d+)', IPython.__version__) if match: groups = match.groups() if int(groups[0]) > major: return True elif int(groups[0]) == major: return int(groups[1]) >= minor return False
def init_ipython_session(argv=[], auto_symbols=False, auto_int_to_Integer=False): """Construct new IPython session. """ import IPython if IPython.__version__ >= '0.11': # use an app to parse the command line, and init config # IPython 1.0 deprecates the frontend module, so we import directly # from the terminal module to prevent a deprecation message from being # shown. if IPython.__version__ >= '1.0': from IPython.terminal import ipapp else: from IPython.frontend.terminal import ipapp app = ipapp.TerminalIPythonApp() # don't draw IPython banner during initialization: app.display_banner = False app.initialize(argv) if auto_symbols: readline = import_module("readline") if readline: enable_automatic_symbols(app) if auto_int_to_Integer: enable_automatic_int_sympification(app) return app.shell else: from IPython.Shell import make_IPython return make_IPython(argv)
def write_result(self, buf): indent = 0 frame = self.frame _classes = ['dataframe'] # Default class. if self.classes is not None: if isinstance(self.classes, str): self.classes = self.classes.split() if not isinstance(self.classes, (list, tuple)): raise AssertionError('classes must be list or tuple, ' 'not %s' % type(self.classes)) _classes.extend(self.classes) if self.notebook: div_style = '' try: import IPython if IPython.__version__ < LooseVersion('3.0.0'): div_style = ' style="max-width:1500px;overflow:auto;"' except ImportError: pass self.write('<div{0}>'.format(div_style)) self.write('<table border="1" class="%s">' % ' '.join(_classes), indent) indent += self.indent_delta indent = self._write_header(indent) indent = self._write_body(indent) self.write('</table>', indent) if self.should_show_dimensions: by = chr(215) if compat.PY3 else unichr(215) # × self.write(u('<p>%d rows %s %d columns</p>') % (len(frame), by, len(frame.columns))) if self.notebook: self.write('</div>') _put_lines(buf, self.elements)
def init_ipython_session(argv=[], auto_symbols=False, auto_int_to_Integer=False): """Construct new IPython session. """ import IPython if V(IPython.__version__) >= '0.11': # use an app to parse the command line, and init config # IPython 1.0 deprecates the frontend module, so we import directly # from the terminal module to prevent a deprecation message from being # shown. if V(IPython.__version__) >= '1.0': from IPython.terminal import ipapp else: from IPython.frontend.terminal import ipapp app = ipapp.TerminalIPythonApp() # don't draw IPython banner during initialization: app.display_banner = False app.initialize(argv) if auto_symbols: readline = import_module("readline") if readline: enable_automatic_symbols(app) if auto_int_to_Integer: enable_automatic_int_sympification(app) return app.shell else: from IPython.Shell import make_IPython return make_IPython(argv)
def _make_message(ipython=True, quiet=False, source=None): """Create a banner for an interactive session. """ from sympy import __version__ as sympy_version from sympy.polys.domains import GROUND_TYPES from sympy.utilities.misc import ARCH from sympy import SYMPY_DEBUG import sys import os python_version = "%d.%d.%d" % sys.version_info[:3] if ipython: shell_name = "IPython" else: shell_name = "Python" info = ['ground types: %s' % GROUND_TYPES] cache = os.getenv('SYMPY_USE_CACHE') if cache is not None and cache.lower() == 'no': info.append('cache: off') if SYMPY_DEBUG: info.append('debugging: on') args = shell_name, sympy_version, python_version, ARCH, ', '.join(info) message = "%s console for SymPy %s (Python %s-%s) (%s)\n" % args if not quiet: if source is None: source = preexec_source _source = "" for line in source.split('\n')[:-1]: if not line: _source += '\n' else: _source += '>>> ' + line + '\n' message += '\n' + verbose_message % {'source': _source} return message
def _make_message(ipython=True, quiet=False, source=None): """Create a banner for an interactive session. """ from sympy import __version__ as sympy_version from sympy.polys.domains import GROUND_TYPES from sympy.utilities.misc import ARCH from sympy import SYMPY_DEBUG import sys import os if quiet: return "" python_version = "%d.%d.%d" % sys.version_info[:3] if ipython: shell_name = "IPython" else: shell_name = "Python" info = ['ground types: %s' % GROUND_TYPES] cache = os.getenv('SYMPY_USE_CACHE') if cache is not None and cache.lower() == 'no': info.append('cache: off') if SYMPY_DEBUG: info.append('debugging: on') args = shell_name, sympy_version, python_version, ARCH, ', '.join(info) message = "%s console for SymPy %s (Python %s-%s) (%s)\n" % args if source is None: source = preexec_source _source = "" for line in source.split('\n')[:-1]: if not line: _source += '\n' else: _source += '>>> ' + line + '\n' doc_version = sympy_version if 'dev' in doc_version: doc_version = "dev" else: doc_version = "%s/" % doc_version message += '\n' + verbose_message % {'source': _source, 'version': doc_version} return message