12

Don't have much expertise in programming. Only picked up Python last summer.

I have installed both Atom and Conda on my computer. Recently, I've used Atom to edit my scripts in Python, then run the scripts via Command Line. As per standard practice, I created Virtual Environments where I installed packages I needed to run different Python scripts.

I now want to use Atom as an IDE, and so have installed the Script package on Atom so I can run my scripts in Atom itself. However, when I tried running a Python script that required the Python numpy package, I got this:

ImportError: No module named 'numpy'

This error is obviously going to appear for other packages that haven't already been installed in the root environment (I think?).

So now, my question is how do I activate the needed Virtual Environment in Atom? In other applications like Jupyter and Spyder, I would activate the Virtual Environment I needed then open the Application via Command Line, but I can't do that with Atom.

(If possible, is there a way to use Virtual Environments created by Conda)

Thanks

m_cheah
  • 131
  • 1
  • 1
  • 8
  • [script-runner](https://atom.io/packages/script-runner) supports virtualenv natively. Have you looked at that? – Dan Lowe Jan 20 '17 at 20:07
  • I just tried installing [script-runner](https://atom.io/packages/script-runner). Unfortunately, there was an error in installation [script-runner installation error](http://i.imgur.com/TumBfAy.png) – m_cheah Jan 20 '17 at 20:26
  • https://atom.io/packages/search?q=virtualenv – Matthew Schuchard Jan 21 '17 at 13:56

2 Answers2

4

One way is to start atom from the activated virtual environment. In this case, executing programs/scripts uses the configured python interpreter and imports the installed in the virtual environment.

EDIT: It's been long though, it might be useful for people redirected to this question.

By installing atom-python-virtualenv you can create, change or deactivate virtual environments with atom editor.

Bussller
  • 1,961
  • 6
  • 36
  • 50
  • This is great. However i have issues with setting up the conda environments path. They are in $HOME/opt/anaconda3/envs/ but that doesn't seem to work well. What do I need to point to? – IceQueeny Mar 25 '22 at 11:59
  • If they're in `$HOME/opt/anaconda3/envs/` then you can point to virtual environment that you want like `$HOME/opt/anaconda3/envs/myPyVirtEnv` where myPyVirtEnv is your environment. – Bussller Mar 26 '22 at 04:15
2

The hydrogen package for Atom works well for this.

You will also need to install Jupyter into your conda environment and Hydrogen should pick up the IPython kernel automatically.

leej3
  • 83
  • 5