Python 在 Atom 中使用 anaconda 环境

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43207427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 22:38:25  来源:igfitidea点击:

Using anaconda environment in Atom

pythonatom-editorhydrogen

提问by Engine

I've install Anaconda (Python 3.6) and tensorflow (python 3.5). I've managed to get it run both on Spyder and on sublime text 3( by making new build system). Now all the is using Atom( which I'm not used to). So I've trying to "tell" Atom to use python in the following folder:

我已经安装了 Anaconda (Python 3.6) 和 tensorflow (python 3.5)。我设法让它在 Spyder 和 sublime text 3 上运行(通过制作新的构建系统)。现在所有的都是使用 Atom(我不习惯)。所以我试图“告诉” Atom 在以下文件夹中使用 python:

C:\users\engine\anaconda3\envs\tensorflow\python.exe

without any success, any idea how to do that or what kind of package should I use( I'm using windows so virtualenv) thanks in advance !

没有任何成功,任何想法如何做到这一点或我应该使用什么样的包(我使用的是 windows so virtualenv)提前致谢!

回答by Aaron Mazie

In your Anaconda terminal, activate your Conda environment and then run 'atom --new-instance'

在您的 Anaconda 终端中,激活您的 Conda 环境,然后运行“atom --new-instance”

回答by Fernando Garcia

If you want to run some python script on different python versions using Atom, I think the best solution is to use atom's Hydrogen package and installing a kernel for every conda env you need, to do it you should open Anaconda's prompt and:

如果你想使用 Atom 在不同的 python 版本上运行一些 python 脚本,我认为最好的解决方案是使用 atom 的 Hydrogen 包并为你需要的每个 conda env 安装一个内核,为此你应该打开 Anaconda 的提示和:

  1. Install jupyter on every conda env you want to work with
  2. Activate the first env that you wish to use on Atom
  3. Create an Ipython kernel for that env with python -m ipykernel install --user --name YourEnvName
  4. Repeat this in all the envs you wish to work with
  1. 在您要使用的每个 conda env 上安装 jupyter
  2. 激活您希望在 Atom 上使用的第一个环境
  3. 为该环境创建一个 Ipython 内核 python -m ipykernel install --user --name YourEnvName
  4. 在您希望使用的所有环境中重复此操作

Sadly if you wish to use some atom's packages like flake8 or python-ide you need to launch atom (simply typing atomon ancaconda prompt) from a conda env that has all the requirements (like python-language-server) and then you can switch between kernels with ease.

遗憾的是,如果您希望使用一些 atom 的包,例如 flake8 或 python-ide,您需要atom从具有所有要求(例如 python-language-server)的 conda env启动 atom(只需在 ancaconda 提示符下键入 ),然后您可以在它们之间切换内核轻松。

If anybody knows how to make Atom and it's packages to recognize some env without launching atom from inside that env, please share :D

如果有人知道如何制作 Atom 并且它的包可以识别某些 env 而无需从该 env 内部启动 atom,请分享:D

回答by Cord Kaldemeyer

You could either use the scriptor hydrogenpackage to run code on different python interpreters. I have already used the first option with different Anaconda environments.

您可以使用脚本包在不同的 Python 解释器上运行代码。我已经在不同的 Anaconda 环境中使用了第一个选项。

Good luck!

祝你好运!

回答by Anouar Benlaqlib

I would guess you want to use the anacondacommand prompt inside your atom IDE. For that you will need to add the conda.exeand pythonpaths to your local variables then it should be good to go!

我猜你想anaconda在你的 atom 中使用命令提示符IDE。为此,您需要将conda.exepython路径添加到您的局部变量中,然后就可以了!

回答by lologop

I had this same issue, and after some exploring, found that this worked well:

我遇到了同样的问题,经过一番探索,发现这很有效:

There is a file (I'm on macOS Catalina 10.15.3):

有一个文件(我在 macOS Catalina 10.15.3 上):

~/.atom/packages/platformio-ide-terminal/lib/platformio-ide-terminal.coffee

~/.atom/packages/platformio-ide-terminal/lib/platformio-ide-terminal.coffee

Look for the autoRunCommand section:

查找 autoRunCommand 部分:

autoRunCommand:
title: 'Auto Run Command'
description: 'Command to run on terminal initialization.'
type: 'string'
default: ''

autoRunCommand:
title: 'Auto Run Command'
description: '在终端初始化时运行的命令。
类型:'字符串'
默认值:''

If you set the default to:

如果您将默认设置为:

'export PATH=~/opt/anaconda3/bin:$PATH'

'导出路径=~/opt/anaconda3/bin:$PATH'

platformio will execute this command every time you start Atom, and it will use the default anaconda python, as specified in the new PATH.

每次启动 Atom 时,platformio 都会执行此命令,并且会使用新 PATH 中指定的默认 anaconda python。

You can then type "conda activate myenvironment" in the platformio terminal and it will work like normal (switch between environments, install packages, etc.). Hope this helps.

然后,您可以在 platformio 终端中键入“conda activate myenvironment”,它会正常工作(在环境之间切换、安装包等)。希望这可以帮助。