本文整理汇总了Python中jupyter_client.kernelspec.KernelSpecManager方法的典型用法代码示例。如果您正苦于以下问题:Python kernelspec.KernelSpecManager方法的具体用法?Python kernelspec.KernelSpecManager怎么用?Python kernelspec.KernelSpecManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jupyter_client.kernelspec
的用法示例。
在下文中一共展示了kernelspec.KernelSpecManager方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def run(self):
# Regular install
install.run(self)
# Post install
print('Installing Ansible Kernel kernelspec')
from jupyter_client.kernelspec import KernelSpecManager
from IPython.utils.tempdir import TemporaryDirectory
kernel_json = {
"argv": ["python", "-m", "ansible_kernel", "-f", "{connection_file}"],
"codemirror_mode": "yaml",
"display_name": "Ansible",
"language": "ansible"
}
with TemporaryDirectory() as td:
os.chmod(td, 0o755)
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
ksm = KernelSpecManager()
ksm.install_kernel_spec(td, 'ansible', user=self.user, replace=True, prefix=self.prefix)
示例2: run
# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def run(self):
# Regular installation
install.run(self)
# Now write the kernelspec
from jupyter_client.kernelspec import KernelSpecManager
from tempfile import TemporaryDirectory
kernel_spec = KernelSpecManager()
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
# TODO: Copy resources once they're specified
kernel_spec.install_kernel_spec(td, 'postgres', user=self.user)
示例3: install_sos_kernel_spec
# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def install_sos_kernel_spec(args):
user = False
prefix = None
if args.sys_prefix:
prefix = sys.prefix
elif args.prefix:
prefix = args.prefix
elif args.user or not _is_root():
user = True
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
# Copy resources once they're specified
shutil.copy(
os.path.join(os.path.split(__file__)[0], 'kernel.js'),
os.path.join(td, 'kernel.js'))
shutil.copy(
os.path.join(os.path.split(__file__)[0], 'logo-64x64.png'),
os.path.join(td, 'logo-64x64.png'))
KS = KernelSpecManager()
KS.log.setLevel(logging.ERROR)
KS.install_kernel_spec(td, 'sos', user=user, prefix=prefix)
print('sos jupyter kernel spec is installed')
示例4: _get_default_kernel_name
# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def _get_default_kernel_name():
return next(iter(KernelSpecManager().find_kernel_specs().keys()))
示例5: install_kernel
# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def install_kernel(cmd):
# Install the kernel spec when we install the package
from ipykernel import kernelspec
from jupyter_client.kernelspec import KernelSpecManager
kernel_name = 'geonotebook%i' % sys.version_info[0]
path = os.path.join(tempfile.mkdtemp(suffix='_kernels'), kernel_name)
try:
os.makedirs(path)
except OSError:
pass
kernel_dict = {
'argv': kernelspec.make_ipkernel_cmd(mod='geonotebook'),
'display_name': 'Geonotebook (Python %i)' % sys.version_info[0],
'language': 'python',
}
with open(os.path.join(path, 'kernel.json'), 'w') as fh:
json.dump(kernel_dict, fh, indent=1)
ksm = KernelSpecManager()
ksm.install_kernel_spec(
path, kernel_name=kernel_name, user=False, prefix=sys.prefix)
shutil.rmtree(path)
# shamelessly taken from ipyleaflet: https://github.com/ellisonbg/ipyleaflet
# Copyright (c) 2014 Brian E. Granger
示例6: get_kernelspec
# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def get_kernelspec(self, name):
"""Get a kernel specification dictionary given a kernel name
"""
ksm = KernelSpecManager()
kernelspec = ksm.get_kernel_spec(name).to_dict()
kernelspec['name'] = name
kernelspec.pop('argv')
return kernelspec