小编jmw*_*lch的帖子

配置IPython以使用powershell而不是cmd

搜索过这个,似乎找不到任何已经问过的人,所以现在就去了.

我开始在Windows 7上切换到IPython作为我的首选shell,我想配置它以便!cmd将命令传递给系统shell 的bang magic()使用PowerShell而不是cmd.exe,所以我可以利用MS所做的增强功能,但不必将我%COMSPEC%改为PowerShell(我的公司仍然使用几个基于CMD的.BAT进行自动化,我不想破坏它们).

我会在顶部发布我的问题,因为答案可能不需要以下任何信息:

  1. 我错过了什么吗?有没有办法在IPython中使用配置文件来指定系统命令解释器?
  2. 如果!1,是否有一种方法可以让我从PowerShell中启动子进程,并使用该进程本地的机器范围环境变量?

研究/测试

通过IPython代码,我看到它os.system()用于将命令发送到shell,而不是subprocess.call().这使事情变得更复杂,因为os.system*只使用COMSPEC,在子进程*中,您可以指定要使用的可执行文件.

我尝试加载PowerShell,设置$env:comspec变量,然后从该shell中启动IPython,但即使COMSPEC出现设置,即使在IPython中,看起来仍然使用CMD:

[PS] C:\> $env:comspec
C:\Windows\system32\cmd.exe
[PS] C:\> $env:comspec = 'powershell.exe'
[PS] C:\> $env:comspec
powershell.exe
[PS] C:\> & 'C:\Python33\Scripts\ipython3.exe'
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's …
Run Code Online (Sandbox Code Playgroud)

windows powershell ipython

11
推荐指数
3
解决办法
4320
查看次数

标签 统计

ipython ×1

powershell ×1

windows ×1