I would like to have a working python environment with python 2.7.12 and a series of packages. It shall be efficient, and yet easy to setup. The anaconda distribution almost satisfies my needs, except that it’s unreasonably slow to load, due to its bundle of system libraries. There are also python version managers such as PYENV and PYTHONZ. The drawback of PYENV is the shims, which are scripts to launch binaries such as python-2 and pip. shims make powerline-client slow, which is undesirable. As to PYTHONZ, it only handles multiple versions of python, no other infrastructure is provided.
After some experimentation, I found that just compile python from source and install it into customized location works just fine. There are some caveats, so I record it here.
I do not like this ideas is a linter test. Linter. How can one use it?
Compile python is easy, just be sure to install bundled pip.
tar -zxvf Python-2.7.12.tgz cd Python-2.7.12 ./configure --prefix=$LOCATION --with-ensurepip=install make make install
After that, you can find python under
$LOCATION/bin/python -m site
will show site-packages under
Install Packages using Pip
We would expect
pip install XXX to install packages into site-packages. But
this does not work in practice. Even with bundled pip, it often installs
packages into system’s site-packages. To install to the correct location, we
have to use
python -m pip.
export PATH=$LOCATION/bin:$PATH python -m pip install PACKAGE
Move Installation Around
I have not yet tested it, but I expect it would be just copy
$LOCATION to a
new location and set
PATH to correct values in new
location. I will try it.