简体   繁体   English

如何在Emacs中将IPython shell的目录设置为与python文件相同的目录?

[英]How to set the directory of IPython shell in Emacs the same as the python file?

I am trying to run IPython in Emacs, using emacs 24.3.1, Python 2.7.4, IPython 0.13.2 on Ubuntu 13.04 我试图在Ubuntu 13.04上使用emacs 24.3.1,Python 2.7.4,IPython 0.13.2在Emacs中运行IPython

When I start an IPython shell within Emacs, it defaults to $HOME directory. 当我在Emacs中启动IPython shell时,它默认为$ HOME目录。 I try to change to my current work directory by 'cd', 'import os, os.chdir()' , but after running a snippet of code, work directory always goes back to $HOME. 我尝试通过'cd', 'import os, os.chdir()'切换到当前工作目录,但是在运行了一段代码后,工作目录总是返回到$ HOME。

Is there a way to change work directory, or start Ipython shell the same as the directory of the edited python file? 有没有一种方法可以更改工作目录,或以与编辑后的python文件相同的目录启动Ipython shell? Thanks. 谢谢。

I found a similar question Setting the working directory of IPython Shell to that of the python file being executed in Canopy but not sure how to implement in Emacs... 我发现了一个类似的问题, 将IPython Shell的工作目录设置为Canopy中正在执行的python文件的工作目录,但不确定如何在Emacs中实现...

With python-mode.el, which should be available at Ubuntu: 使用python-mode.el,应该在Ubuntu上可用:

Run IPython via Mx IPython 通过Mx IPython运行IPython

Customizations applicable in this case: 适用于这种情况的自定义:

py-execute-directory

When set, stores the file's default directory-name py-execute-... functions act upon. 设置后,将存储文件默认的目录名py-execute -...函数。

resp. 分别

py-use-current-dir-when-execute-p

When t', current directory is used by Python-shell for output of py-execute-buffer' and related commands. 当为t', current directory is used by Python-shell for output of py-execute-buffer'和相关命令。

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

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