Using anaconda environment in Atom
Asked Answered
M

9

30

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:

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 !

Mide answered 4/4, 2017 at 12:35 Comment(1)
You can installed autocomplete-python and added my conda env to it.Polymorphonuclear
S
48

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

Striper answered 9/4, 2018 at 16:40 Comment(1)
when I run atom --new-instance, I got this message Unable to start the Python language server. and all packages I downloaded can't be used.Barytes
C
11

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:

  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

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

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

Categorical answered 18/9, 2018 at 21:4 Comment(0)
P
5

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):

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

Look for the autoRunCommand section:

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

If you set the default to:

'export 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.

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.

Pleistocene answered 18/2, 2020 at 19:44 Comment(0)
H
1

You could either use the script or hydrogen package to run code on different python interpreters. I have already used the first option with different Anaconda environments.

Good luck!

Hammack answered 18/5, 2017 at 18:0 Comment(0)
K
0

I would guess you want to use the anaconda command prompt inside your atom IDE. For that you will need to add the conda.exe and python paths to your local variables then it should be good to go!

Kossuth answered 14/2, 2019 at 12:35 Comment(0)
C
0

For using Python cmd (anaconda environment) in Atom :-

Install "autocomplete-python" package in Atom. { Welcome Guide -> Install a Package -> Open Istaller -> Install -> (Search) autocomplete-python -> Install }

Install "platformio-ide-terminal" package in Atom. { Welcome Guide -> Install a Package -> Open Istaller -> Install -> (Search) platformio-ide-terminal -> Install }

Then, Open Platformio-Ide-Terminal Settings { Welcome Guide -> Install a Package -> Open Istaller -> Packages -> platformio-ide-terminal -> settings }.

Change Shell Override to "C:\WINDOWS\system32\cmd.exe" . {platformio-ide-terminal -> settings -> Core -> Shell Override}

Now, you can see a plus(+) sign at left down corner side of Atom editor. Click on that plus(+) sign, cmd terminal will open on atom.

Use "cd" command to go into anaconda folder.

Then type "python", now you will see the python version in your terminal.
example:

C:\Users\Ankush>cd anaconda3

C:\Users\Ankush\Anaconda3>python

Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

print("Hello World") Hello World

Thanks

Ankush

Constipation answered 3/8, 2020 at 5:13 Comment(0)
H
0

I tried a lot on activating environment in atom editor though i was able to run the conda activate in command prompt but not in atom editor terminal.

Go to the platformio-ide-terminal settings and replace the default terminal with c:\windows\system32\cmd.exe and this fixed my problem in a single go.

Hellcat answered 11/5, 2021 at 5:23 Comment(0)
F
0

I found another very pragmatic solution for Windows: create a batch file in your Atom executable folder:

call C:\Users\<yourUserFolder>\anaconda3\Scripts\activate.bat C:\Users\<yourUserFolder>\anaconda3
call conda activate tensorflow
call C:\Users\<yourUserFolder>\AppData\Local\atom\atom.exe

Create shortcut inside your favorite location, give it a nice name and set the icon. It looks like it shipped with Atom. Repeat for every environment.

Ofc this solution comes with the downside of the need of restarting Atom for each environment.

Tested with Atom addon script.

Fingertip answered 28/7, 2021 at 17:20 Comment(0)
D
0

script package configuration (in atom) rather frustrated!:

$ pwd
/home/<UserID>/.atom/packages/script
$ vim lib/grammars/python.js
  "File Based": {
    // me using miniconda here
    // command: "python", // orig
    command: "/opt/miniconda/bin/python",
Diet answered 7/2, 2022 at 12:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.