Python

From Bitpost wiki
Revision as of 14:26, 8 February 2018 by M (talk | contribs)

Installation on Ubuntu

Virtual environments are great. Best to use them right out of the gate, as Ubuntu apparently has hacked up their version.

sudo apt update
sudo apt install virtualenv
virtualenv my_python
source my_pyton/bin/activate
pip install --upgrade pip

Here are the things I had to install to get my work env going:

sudo apt install python-pip libxml2-dev libxslt1-dev

And that never got me there. More lessons to learn...

Configure pycharm to use a virtualenv

File > Settings > Project: ate > Project Interpreter > click Gear in top-right > Add Local

Select the python bin eg:

/home/m/Envs/ate/bin/python2

Dependency Control

Great suggestion for python dependency control:

   use two dependency files, one general, and one for current freeze version numbers
   node.js has a similar approach with its new lock files (good stuff i think)
   gentoo just fucking gets it right (nearly) every time, somehow
   ---
   # requirements-to-freeze.txt (typical mostly-unconstrained Method #1) is used to specify your top-level dependencies, and any explicit versions you need to specify.
   # requirements.txt (fully-versioned Method #2) contains the output of $ pip freeze after $ pip install requirements-to-freeze.txt has been run.
   $ cd project-repo
   $ pip install -r requirements-to-freeze.txt --upgrade
   Installing collected packages: six, enum34, ipaddress, ...
   $ pip freeze > requirements.txt
   # The best of both worlds.