Python deployments

From Freephile Wiki
Revision as of 09:52, 27 February 2017 by Freephile (talk | contribs) (brief updates for 2017)

Jump to navigation Jump to search

See Digital Ocean's quick guide to setting up a local Python programming environment, including virtual environments, which is what I did for SoundScrape Btw, SoundScrape is a neat tool to download sound files from SoundCloud. [1]

Hynek Schlawack (from 2013)

Python Packaging[edit | edit source]

In the old days (2015) there were still debates about how to package Python and install stuff. Now, it's settled. Use pip. Easy_install is dead. See the docs. Also note that venv is the successor to virtualenv

Basic PIP[edit | edit source]

Do NOT (normally) use sudo with pip. Use a virtual environment:

$ virtualenv myenv
.. some output ..
$ source myenv/bin/activate
(myenv) $ pip install what-i-want

You only use sudo or elevated permissions when you want to install stuff for the global, system-wide Python installation.

It is best to use a virtual environment which isolates packages for you. That way you can play around without polluting the global python install.

As a bonus, virtualenv does not need elevated permissions.

  • Installing a package is as simple as pip install foo
  • Upgrades are pip install --upgrade foo
  • pip uninstall foo if you want to remove foo

References[edit source]

  1. cd
    mkdir environments
    cd environments/
    pyvenv my_env
    source my_env/bin/activate
    pip install --upgrade pip
    pip install soundscrape
    pip install soundscrape --upgrade
    soundscrape https://soundcloud.com/pianoman_weddings/coldplay