How do I set up virtualenv exclusively for my new atom installation on mac?


#1

I have just migrated to a new Mac from Windows and decided to ditch PyCharm for ATOM as my IDE. I currently have Anaconda installed which has taken over the default Mac Python interpreter.

I use Anaconda and its installed for my data science grad school python class, so I prefer to leave that environment and packages untouched and start from scratch building a Python environment for my projects in ATOM.

I have only installed Anaconda and Atom on the new setup and done nothing to their default state.

So what do I need for my ATOM set up?

  1. A fresh Python environment for my ATOM projects

  2. The latest Python 2 interpreter for this newly created Python environment

  3. A step to step guide for achieving this desired set up.

I am sorry if this sound so noobish but I have never set up an environment before so I need guidance because of the scattered Virtualenv information on the internet.

Many thanks in advance. ATOM is exactly what I wanted from an IDE.


#2

I have used pyenv, which contains step-by-step instructions for setting it up. You install all versions of Python globally, then you use pyenv to determine which one you want for each specific folder. If you find that you have difficulty understanding the setup instructions, I can help you.


#3

Can you please provide the instructions for pyenv in setting up using my
case as an example?

I just need to understand the process logically.

Thanks


#4
  1. Use Homebrew to install pyenv.
  2. Use Homebrew to install pyenv-virtualenv.
  3. Create the virtual environment.
  4. Write a shell script that activates the virtual environment and then starts Atom. This will be necessary for Atom to use the Python interpreter and site-packages/ directory present in the virtual environment.

#5

Awesome information.

Can you please elaborate on how to create the shell script that activates a
specific environment and then starts ATOM?

Sorry if I’m bugging you. I’m very new at all these


#6

This is something you’ll want to get some basic familiarity with if you’re doing programming. Shell scripts can save you a lot of time, and unless you’re doing a whole lot of them, you don’t need to memorize much (it’s all very easy to do by reference). Here’s a good tutorial.

Here’s an example script that should achieve what you want, assuming you’ve named your projects folder projects and have set up a Python 2 virtual environment via pyenv named python2:

#!/bin/bash
# Move to projects directory
cd ~/projects
# Activate virtualenv
pyenv activate python2
# Open Atom at the current location
atom .

#7

Thanks for your time. Great insights


#8

No problem. :slight_smile: