简体   繁体   English

Spacemacs将python shell设置为Anaconda3路径

[英]Spacemacs set python shell to Anaconda3 path

I have started to use Spacemacs to edit python files and also to use org-mode, but now I want to run python from Spacemacs instead of running Anaconda Prompt. 我已经开始使用Spacemacs编辑python文件以及使用org-mode,但是现在我想从Spacemacs运行python而不是运行Anaconda Prompt。

I've written this in .spacemacs file with SPC fed : 我已经用SPC fed .spacemacs写在.spacemacs文件中:

(defun dotspacemacs/user-init ()
  "Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
 This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
  (setq python-shell-interpreter "C:/Users/Mahesvara/Documents/Personal_Documents/Programs/Anaconda3/python.exe")
  )

But when I try to run the script with Cc Cp it gives the following error: Searching for program: No such file or directory, python 但是,当我尝试使用Cc Cp运行脚本时,出现以下错误: Searching for program: No such file or directory, python

I am not entirely familiar with Spacemacs on Windows, but here is my go at this... 我对Windows上的Spacemacs并不完全熟悉,但是这是我的努力...

Command line is not a shell 命令行不是shell

Note that anaconda prompt is not a shell, it is an command prompt interface to anaconda ( see here ). 请注意,anaconda提示符不是shell,它是anaconda的命令提示符界面( 请参见此处 )。

Windows uses cmd. Windows使用cmd。 Spacemacs, Unix, and Python use shells , and are a completely different interface. Spacemacs,Unix和Python使用shell ,它们是一个完全不同的接口。

Welcome to Spacemacs 欢迎来到Spacemacs

What you put in that variable shouldn't be a file path. 您在该变量中输入的内容不应是文件路径。 It should be a name of a program. 它应该是程序的名称。 Emacs has a list of places where executable are stored. Emacs列出了可执行文件的存储位置。 This variable is called exec-path . 此变量称为exec-path Here is how to set it. 是设置方法。

I would recommend not modifying it, but viewing it 我建议不要修改它,而要查看它

(print exec-path)

There then needs to be a python shell in one of those paths (ie python, ipython, etc.). 这些路径之一(例如python,ipython等)中需要有一个python shell。

A more experienced Windows developer may want to disagree with this. 经验更丰富的Windows开发人员可能希望对此表示不同意见。 But it may be helpful to install some Babun/Cygwin shell to install python with. 但是安装一些Babun / Cygwin shell来安装python可能会有所帮助。 Especially if you are using Spacemacs. 特别是在使用Spacemacs的情况下。 This would allow you to run in a more Unix-y environment which works better for Spacemacs. 这将使您能够在更适用于Spacemacs的Unix-y环境中运行。 Just make sure the home directories match up. 只要确保主目录匹配即可。

Once you have a python shell program installed in one of the exec-path 's, You should be able to: exec-path之一中安装了python shell程序后,您应该能够:

(setq python-shell-interpreter "python")

Change python to whatever python shell you chose. 将python更改为您选择的任何python shell。

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

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