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
  • 7
  • [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 – Matt Schuchard Jan 21 '17 at 13:56

2 Answers2

3

One way is to start atom from the activated virtual environment. In this case, running using script uses the the configured python interpreter and imports the packages installed and available 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,639
  • 3
  • 31
  • 36
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
  • 53
  • 5