本文整理汇总了Python中IPython.zmq.ipkernel.IPKernelApp.initialize方法的典型用法代码示例。如果您正苦于以下问题:Python IPKernelApp.initialize方法的具体用法?Python IPKernelApp.initialize怎么用?Python IPKernelApp.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.zmq.ipkernel.IPKernelApp
的用法示例。
在下文中一共展示了IPKernelApp.initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InternalIPKernel
# 需要导入模块: from IPython.zmq.ipkernel import IPKernelApp [as 别名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 别名]
class InternalIPKernel(object):
"""Class for managing an IPython kernel inside of QGIS.
IPython normally runs kernels in seperate processes, but this setup is
limiting in the case of QGIS because external kernels cannot access the
data and variables that QGIS is working with. This class manages an
in-process kernel and is capable of launching external consoles that can
attach to the kernel.
IPython Consoles are run as external processes because they rely on
Version 2 of the PyQt api and QGIS is using Version 1 which is
incompatible.
"""
def __init__(self):
self.ipkernel = IPKernelApp()
self.ipkernel.initialize(['python',
# Ensure the Kernel pre-loads the same modules as are available
# from the QGIS python console.
"--c='from qgis.core import *;import qgis.utils;'"])
# Ensure we use an event loop that is QGIS-friendly.
self.ipkernel.kernel.eventloop = loop_qgis
self.ipkernel.start()
# To create and track active qt consoles
self._qtconsole_cmd = ['ipython', 'qtconsole', '--existing'] + \
[os.path.basename(self.ipkernel.connection_file)]
self.consoles = []
def new_qt_console(self, evt=None):
self.consoles.append(subprocess.Popen(self._qtconsole_cmd))
def cleanup_consoles(self, evt=None):
for c in self.consoles:
c.kill()
示例2: pylab_kernel
# 需要导入模块: from IPython.zmq.ipkernel import IPKernelApp [as 别名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 别名]
def pylab_kernel(gui):
"""Launch and return an IPython kernel with pylab support for the desired gui
"""
kernel = IPKernelApp()
kernel.initialize(['python', '--pylab=%s' % gui,
#'--log-level=10'
])
return kernel
示例3: pylab_kernel
# 需要导入模块: from IPython.zmq.ipkernel import IPKernelApp [as 别名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 别名]
def pylab_kernel(gui):
"""Launch and return an IPython kernel with pylab support for the desired gui
"""
kernel = IPKernelApp()
# FIXME: we're hardcoding the heartbeat port b/c of a bug in IPython 0.11
# that will set it to 0 if not specified. Once this is fixed, the --hb
# parameter can be omitted and all ports will be automatic
kernel.initialize(['python', '--pylab=%s' % gui, '--hb=19999',
#'--log-level=10'
])
return kernel
示例4: locals
# 需要导入模块: from IPython.zmq.ipkernel import IPKernelApp [as 别名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 别名]
sys.path.remove(osp.dirname(__file__))
except ValueError:
pass
locals().pop('__file__')
__doc__ = ''
__name__ = '__main__'
if os.environ.get('IPYTHON_KERNEL', False):
# IPython >=v0.11 Kernel
from IPython.zmq.ipkernel import IPKernelApp
__ipythonkernel__ = IPKernelApp().instance()
__ipythonkernel__.initialize(sys.argv[1:])
__ipythonshell__ = __ipythonkernel__.shell
__ipythonkernel__.start()
elif os.environ.get('IPYTHON', False):
sys.path.insert(0, '')
if os.name == 'nt':
# Windows platforms: monkey-patching *pyreadline* module
# to make IPython work in a remote process
from pyreadline import unicode_helper
unicode_helper.pyreadline_codepage = "ascii"
# For pyreadline >= v1.7:
from pyreadline import rlmain
class Readline(rlmain.Readline):
def __init__(self):