Activating Python Virtual Environment in Atom

m_cheah picture m_cheah · Jan 20, 2017 · Viewed 9k times · Source

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

Answer

Bussller picture Bussller · Dec 21, 2017

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.