如何在Emacs中运行python解释器?

时间:2022-06-07 07:13:54

I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7.

我刚下载了GNU emacs23.4,我已经在Windows7中安装了python3.2。

I have been using Python IDLE to edit python files.

我一直在使用Python IDLE来编辑python文件。

The problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on "switch to interpreter", then it says "Searching for program: no such file or directory, python"

问题是我可以用Emacs编辑python文件,但我不知道如何在Emacs中运行python解释器。当我点击“切换到解释器”,然后它说“搜索程序:没有这样的文件或目录,python”

Someone says i need to make some change on .emacs file, but i do not know where to look for.

有人说我需要对.emacs文件进行一些更改,但我不知道在哪里寻找。

And I am very unexperienced and just started to learn programming. I am not familiar with commonly used terminologies. I have been searching for solutions but most of the articles i find on the Internet only confuse me.

我非常缺乏经验,刚开始学习编程。我不熟悉常用的术语。我一直在寻找解决方案,但我在互联网上找到的大多数文章只会让我感到困惑。

so the questions are:

所以问题是:

  1. how do i run python interpreter in Emacs?
  2. 我如何在Emacs中运行python解释器?

  3. are there different kind of python interpreter? if so, why do they have different interpreters for one language?
  4. 有不同类型的python解释器?如果是这样,为什么他们为一种语言有不同的口译员?

8 个解决方案

#1


19  

Place this in your .emacs to let emacs know where is your python interpretor

将它放在你的.emacs中让emacs知道你的python解释器在哪里

 (setq python-shell-interpreter "path\to\your\python3.2")

To learn about.emacs you can read about it in Emacs itself.(Emacs comes with good info manuals and info mode to help to read that manual).

要了解about.emacs,您可以在Emacs中阅读它。(Emacs附带了很好的信息手册和信息模式,以帮助阅读该手册)。

press the following in emacs

在emacs中按以下键

M-: (info "(Emacs)Init file") RET.

M- :( info“(Emacs)Init文件”)RET。

#2


13  

C-c C-z can do this. It is the key-binding for the command python-switch-to-python

C-c C-z可以做到这一点。它是命令python-switch-to-python的键绑定

#3


8  

IF you have python installed, try M-x python-shell (press and hold ALT while pressing x, then type python-shell, then press enter)

如果安装了python,请尝试使用M-x python-shell(在按x的同时按住ALT,然后键入python-shell,然后按回车键)

There are different language implementations if that is what you are asking (see a list of them here).

如果您要问的话,有不同的语言实现(请参阅此处的列表)。

#4


4  

In emacs 24.5.1 with spacemacs 105 (develop branch) and the Python layer enabled ("layer" is a spacemacs concept; see their documentation), I find python-shell-switch-to-shell opens an IPython buffer. I tested macropy.console in such a buffer and it works great.

在emacs 24.5.1中使用spacemacs 105(开发分支)并启用Python层(“layer”是一个spacemacs概念;请参阅他们的文档),我发现python-shell-switch-to-shell打开了一个IPython缓冲区。我在这样的缓冲区中测试了macropy.console,效果很好。

#5


2  

You probably need to have Python in your windows PATH environment variable. Can you start the interpreter just by typing python in the command window?

您可能需要在Windows PATH环境变量中使用Python。你能在命令窗口输入python来启动解释器吗?

I don't have anything special in my emacs.el, but the start interpreter command works just fine.

我的emacs.el中没有任何特殊内容,但start interpreter命令工作得很好。

Also, I recommend reading this blog post, as it contains many useful tips and packages worth installing if using Emacs as a Python IDE.

此外,我建议阅读此博客文章,因为它包含许多有用的提示和包,如果使用Emacs作为Python IDE,值得安装。

#6


2  

In emacs 25.3.1 I use this to open up a python shell:

在emacs 25.3.1中我用它来打开一个python shell:

M-x run-python

After first adding this to my .emacs file:

首先将其添加到我的.emacs文件中:

(setq python-shell-interpreter "/usr/local/bin/python3")

#7


1  

To simply open an interpreter, you can also use M-x python. If that does not work, try M-x python and hit TAB, which will list more options via auto-completion. One of them should work k if you have python installed.

要简单地打开一个解释器,你也可以使用M-x python。如果这不起作用,请尝试M-x python并点击TAB,它将通过自动完成列出更多选项。如果你安装了python,其中一个应该工作。

If you are inclined, it may be worthwhile to check out the Emacs python modes as well - http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMode;id=PythonProgrammingInEmacs

如果你有倾向,那么查看Emacs python模式也许是值得的 - http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMode;id=PythonProgrammingInEmacs

#8


0  

In emacs 24.2 there is python-switch-to-python

在emacs 24.2中有python-switch-to-python

#1


19  

Place this in your .emacs to let emacs know where is your python interpretor

将它放在你的.emacs中让emacs知道你的python解释器在哪里

 (setq python-shell-interpreter "path\to\your\python3.2")

To learn about.emacs you can read about it in Emacs itself.(Emacs comes with good info manuals and info mode to help to read that manual).

要了解about.emacs,您可以在Emacs中阅读它。(Emacs附带了很好的信息手册和信息模式,以帮助阅读该手册)。

press the following in emacs

在emacs中按以下键

M-: (info "(Emacs)Init file") RET.

M- :( info“(Emacs)Init文件”)RET。

#2


13  

C-c C-z can do this. It is the key-binding for the command python-switch-to-python

C-c C-z可以做到这一点。它是命令python-switch-to-python的键绑定

#3


8  

IF you have python installed, try M-x python-shell (press and hold ALT while pressing x, then type python-shell, then press enter)

如果安装了python,请尝试使用M-x python-shell(在按x的同时按住ALT,然后键入python-shell,然后按回车键)

There are different language implementations if that is what you are asking (see a list of them here).

如果您要问的话,有不同的语言实现(请参阅此处的列表)。

#4


4  

In emacs 24.5.1 with spacemacs 105 (develop branch) and the Python layer enabled ("layer" is a spacemacs concept; see their documentation), I find python-shell-switch-to-shell opens an IPython buffer. I tested macropy.console in such a buffer and it works great.

在emacs 24.5.1中使用spacemacs 105(开发分支)并启用Python层(“layer”是一个spacemacs概念;请参阅他们的文档),我发现python-shell-switch-to-shell打开了一个IPython缓冲区。我在这样的缓冲区中测试了macropy.console,效果很好。

#5


2  

You probably need to have Python in your windows PATH environment variable. Can you start the interpreter just by typing python in the command window?

您可能需要在Windows PATH环境变量中使用Python。你能在命令窗口输入python来启动解释器吗?

I don't have anything special in my emacs.el, but the start interpreter command works just fine.

我的emacs.el中没有任何特殊内容,但start interpreter命令工作得很好。

Also, I recommend reading this blog post, as it contains many useful tips and packages worth installing if using Emacs as a Python IDE.

此外,我建议阅读此博客文章,因为它包含许多有用的提示和包,如果使用Emacs作为Python IDE,值得安装。

#6


2  

In emacs 25.3.1 I use this to open up a python shell:

在emacs 25.3.1中我用它来打开一个python shell:

M-x run-python

After first adding this to my .emacs file:

首先将其添加到我的.emacs文件中:

(setq python-shell-interpreter "/usr/local/bin/python3")

#7


1  

To simply open an interpreter, you can also use M-x python. If that does not work, try M-x python and hit TAB, which will list more options via auto-completion. One of them should work k if you have python installed.

要简单地打开一个解释器,你也可以使用M-x python。如果这不起作用,请尝试M-x python并点击TAB,它将通过自动完成列出更多选项。如果你安装了python,其中一个应该工作。

If you are inclined, it may be worthwhile to check out the Emacs python modes as well - http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMode;id=PythonProgrammingInEmacs

如果你有倾向,那么查看Emacs python模式也许是值得的 - http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMode;id=PythonProgrammingInEmacs

#8


0  

In emacs 24.2 there is python-switch-to-python

在emacs 24.2中有python-switch-to-python