Skip to content

Instantly share code, notes, and snippets.

@richardsalex
Created August 5, 2016 16:08
Show Gist options
  • Save richardsalex/b7e420a8dba0da0f44eeda90c2c827fe to your computer and use it in GitHub Desktop.
Save richardsalex/b7e420a8dba0da0f44eeda90c2c827fe to your computer and use it in GitHub Desktop.

Revisions

  1. richardsalex created this gist Aug 5, 2016.
    27 changes: 27 additions & 0 deletions python_env.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    # Installing Python and Jupyter Notebooks on OS X

    For the most part, everything will be done using OS X's Terminal.

    We need to install the following (in this order) to get up and running:

    1. [Homebrew](http://brew.sh/) (a package manager for OS X)
    2. Python (via Homebrew)
    3. Virtualenv (via Python's pip)
    4. Virtualenvwrapper (also via Python's pip)

    We'll also need to create/alter your `.bash_profile` so that every time you open up a new Terminal window, you'll have access to these virtual environments and commands. The following will need to be added to whatever's already there or put inside a blank text file and saved as `.bash_profile` inside of your user folder (`/Users/<username>/`).

    ~~~bash
    export WORKON_HOME=$HOME/Envs
    source /usr/local/bin/virtualenvwrapper.sh
    ~~~

    ### Next steps

    From there, we'll create a new virtual environment and install a few third-party Python libraries like *[Jupyter](http://jupyter.org/)*, *[requests](http://docs.python-requests.org/en/master/)* and *[BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/)* which can help with scraping tasks.

    The whole virtual environment thing is probably overkill for someone just starting out; I don't even really run into situations where it's critical. It's something developers use to keep different versions of third-party libraries and their dependencies (other libraries that help them work) from conflicting with each other.

    It's like starting with a clean slate. If you mess something up, it's typically going to be limited to the virtual environment, too, so you can just delete it and create another.

    So what's the deal with *virtualenvwrapper*? It basically gives you [a set of commands](https://virtualenvwrapper.readthedocs.io/en/latest/) which make it much easier to hop in and out of these virtual environments.