简体   繁体   English

从System Shell执行Ipython脚本

[英]Executing Ipython Script from System Shell

In the same way we can execute regular Python using shebangs (or PyLauncher on windows), can we do the same with Ipython and .ipy files? 以相同的方式,我们可以使用shebangs(或Windows上的PyLauncher)执行常规的Python,是否可以对Ipython和.ipy文件执行相同的操作?

Registering IPython in Windows registry so double-click .ipy launches IPython Console. 在Windows注册表中注册IPython,以便双击.ipy启动IPython控制台。 Or from linux just adding an 'i' to '/usr/bin/python' and execute. 或者从linux只需在'/ usr / bin / python'中添加'i'并执行。

In Windows this would be really helpful, because one of the trickest parts of "system integration" is the command line arguments. 在Windows中,这确实很有用,因为“系统集成”的最棘手的部分之一就是命令行参数。 If these could be tucked into a text file on the shebang (pylauncher style), that would be fabulous. 如果可以将这些文件塞进shebang上的文本文件中(pylauncher风格),那就太好了。

Not sure if I fully understand your problem, but you can create a py.ini file on Windows as described in the Customized Commands section of PEP 397 of which PyLauncher is an implementation. 不知道我是否完全理解您的问题,但是您可以按照PEP 397的“自定义命令”部分中描述在 Windows上创建py.ini文件,PyLauncher是该文件的实现。

[commands]
ipython=C:\Anaconda\Scripts\ipython.exe -v

Changing the path to where your local IPython is installed. 更改安装本地IPython的路径。 If you associate the .ipy file extension with the pylauncher executable ( typically C:\\Windows\\py.exe and you can save the py.ini file to the same path ) and use the shebang below at the top of your .py/.ipy files they should run with ipython and the options specified in the py.ini file 如果将.ipy文件扩展名与pylauncher可执行文件(通常为C:\\ Windows \\ py.exe关联,并且可以将py.ini文件保存到同一路径),然后使用.py /顶部下面的shebang。 ipy文件,它们应与ipython一起运行,并在py.ini文件中指定选项

#! ipython

You can also associate the ipython.exe with .ipy files on Windows and it will run the .ipy files. 您还可以将ipython.exe与Windows上的.ipy文件相关联,它将运行.ipy文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM