Repository: spack/spack

Issue:
flake8 command fails with: ImportError: No module named backports.configparser
I installed py-flake8, loaded the corresponding lmod module (which recursively loaded prereqs) and/but the flake8 command failed with `ImportError: No module named backports.configparser` (full message below).

I've read through #4154 and #6886.  

I'm reporting this because I *do* have the module for `py-setuptools/39.0.1-py2.7-6jfae2n` loaded.  Here's my  `PYTHONPATH` (I didn't think to grab this until *after* I'd activated `py-flake8`, but I don't think that would have changed anything).

```console
[hartzell@ip-10-96-1-107 spack]$ printenv PYTHONPATH | sed -e 's/:/\n/g'
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-configparser-3.5.0-h3atyxvuwid6gx76hxkcdmrt2u4dt3ez/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-pycodestyle-2.3.1-xywxzk5sxavwdtcjojcugsnjxolp3at3/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-pyflakes-1.6.0-7pgh7f6oulvjn5742ndl3wwxxb5knjd6/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-mccabe-0.6.1-si5eqfscdbnsujtuj72kwyfpjri7nl22/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-enum34-1.1.6-aqs222qt2a7g3yuzygtzvfeinp4dbdsw/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/httpie-0.9.9-wg4b3aahak4pdnbpvoqhx4gjvs235khb/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-setuptools-39.0.1-6jfae2npd2ff3trjznsglbud6dzr2hwr/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-pygments-2.2.0-6vm4e7yulsroo5fzy2x2ep3kxa2ahvy4/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-argparse-1.4.0-4btjajngnldvugi7fswrrqz5j6p23lbg/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-requests-2.14.2-e2hgw2igryigbhxjbnd2act5b7hisa3j/lib/python2.7/site-packages
/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-pysocks-1.6.6-kp3sjeg54hnamhwaywvjh7u4b5mor4vp/lib/python2.7/site-packages
```

If I activate `py-flake8`, then the `flake8` command works.

Here's the `modules.yaml` file I have in place:

```yaml
modules:
  enable::
    - lmod
    - tcl
  tcl:
    # hash_length: 0
    blacklist:
      - '%gcc@4.8.2'
      - '%gcc@4.8.5'
    all:
      suffixes:
        '+jit': jit
        '^python@2.7': 'py2.7'
        '^python@3.6': 'py3.6'
    naming_scheme: '${PACKAGE}/${VERSION}'
    ^python:
      autoload:  'direct'
  lmod:
    core_compilers:
      - 'gcc@4.8.5'
      - 'gcc@4.8.2'
      - 'gcc@4.8'
    # hash_length: 0
    whitelist:
      - gcc
    blacklist:
      - '%gcc@4.8.2'
      - '%gcc@4.8.5'
    verbose_autoload: false
    all:
      suffixes:
        '+jit': jit
        '^python@2.7': 'py2.7'
        '^python@3.6': 'py3.6'
      filter:
        environment_blacklist: ['CPATH', 'LIBRARY_PATH', 'LD_LIBRARY_PATH']
    ^python:
      autoload:  'direct'
      filter:
        environment_whitelist: ['LD_LIBRARY_PATH']
```

Here's what I did:

```
[hartzell@ip-10-96-1-107 spack]$ spack install py-flake8
==> bzip2 is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/bzip2-1.0.6-cwlahssuozgae3vmamd2ymjk7ds5twpg
==> pkgconf is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/pkgconf-1.4.2-tj3xey2py2atqwjgo3hcv7bfnp6gesw3
==> ncurses is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/ncurses-6.1-b3yjgmvck5ev56he4tppklmp3qicnndd
==> readline is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/readline-7.0-ozyym5ybrl5hzcmeirinvz4iz3xmpuic
==> gdbm is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/gdbm-1.14.1-dimgxtnjbwh7kt4bcyj2aphh3pr52mhw
==> zlib is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/zlib-1.2.11-56rgaosb4ij2unhwfsnbiv7z3qjximce
==> openssl is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/openssl-1.0.2n-66jppsdf5l5ej5iw24mx6r7eh2egcedc
==> sqlite is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/sqlite-3.23.1-lksczst4ht2kigmavfnpfp2ojylfh4zf
==> python is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/python-2.7.15-5p2y647jgartus36kvo4vgyzkvoam3a7
==> py-setuptools is already installed in /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-setuptools-39.0.1-6jfae2npd2ff3trjznsglbud6dzr2hwr
==> Installing py-configparser
==> Fetching https://pypi.io/packages/source/c/configparser/configparser-3.5.0.tar.gz
#################################################################################################################################### 100.0%#################################################################################################################################### 100.0%
==> Staging archive: /home/hartzell/spack/var/spack/stage/py-configparser-3.5.0-h3atyxvuwid6gx76hxkcdmrt2u4dt3ez/configparser-3.5.0.tar.gz
==> Created stage in /home/hartzell/spack/var/spack/stage/py-configparser-3.5.0-h3atyxvuwid6gx76hxkcdmrt2u4dt3ez
==> No patches needed for py-configparser
==> Building py-configparser [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed py-configparser
  Fetch: 0.37s.  Build: 1.24s.  Total: 1.61s.
[+] /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-configparser-3.5.0-h3atyxvuwid6gx76hxkcdmrt2u4dt3ez
==> Installing py-enum34
==> Fetching https://pypi.io/packages/source/e/enum34/enum34-1.1.6.tar.gz
#################################################################################################################################### 100.0%
==> Staging archive: /home/hartzell/spack/var/spack/stage/py-enum34-1.1.6-aqs222qt2a7g3yuzygtzvfeinp4dbdsw/enum34-1.1.6.tar.gz
==> Created stage in /home/hartzell/spack/var/spack/stage/py-enum34-1.1.6-aqs222qt2a7g3yuzygtzvfeinp4dbdsw
==> No patches needed for py-enum34
==> Building py-enum34 [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed py-enum34
  Fetch: 0.32s.  Build: 1.04s.  Total: 1.36s.
[+] /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-enum34-1.1.6-aqs222qt2a7g3yuzygtzvfeinp4dbdsw
==> Installing py-mccabe
==> Fetching https://github.com/PyCQA/mccabe/archive/0.6.1.tar.gz
-#O=#    #     #
==> Staging archive: /home/hartzell/spack/var/spack/stage/py-mccabe-0.6.1-si5eqfscdbnsujtuj72kwyfpjri7nl22/0.6.1.tar.gz
==> Created stage in /home/hartzell/spack/var/spack/stage/py-mccabe-0.6.1-si5eqfscdbnsujtuj72kwyfpjri7nl22
==> Ran patch() for py-mccabe
==> Building py-mccabe [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed py-mccabe
  Fetch: 0.52s.  Build: 1.01s.  Total: 1.54s.
[+] /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-mccabe-0.6.1-si5eqfscdbnsujtuj72kwyfpjri7nl22
==> Installing py-pycodestyle
==> Fetching https://github.com/PyCQA/pycodestyle/archive/2.3.1.tar.gz
#=#=-#    #
==> Staging archive: /home/hartzell/spack/var/spack/stage/py-pycodestyle-2.3.1-xywxzk5sxavwdtcjojcugsnjxolp3at3/2.3.1.tar.gz
==> Created stage in /home/hartzell/spack/var/spack/stage/py-pycodestyle-2.3.1-xywxzk5sxavwdtcjojcugsnjxolp3at3
==> No patches needed for py-pycodestyle
==> Building py-pycodestyle [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed py-pycodestyle
  Fetch: 0.48s.  Build: 1.12s.  Total: 1.60s.
[+] /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-pycodestyle-2.3.1-xywxzk5sxavwdtcjojcugsnjxolp3at3
==> Installing py-pyflakes
==> Fetching https://github.com/PyCQA/pyflakes/archive/1.6.0.tar.gz
#=#=-#    #
==> Staging archive: /home/hartzell/spack/var/spack/stage/py-pyflakes-1.6.0-7pgh7f6oulvjn5742ndl3wwxxb5knjd6/1.6.0.tar.gz
==> Created stage in /home/hartzell/spack/var/spack/stage/py-pyflakes-1.6.0-7pgh7f6oulvjn5742ndl3wwxxb5knjd6
==> No patches needed for py-pyflakes
==> Building py-pyflakes [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed py-pyflakes
  Fetch: 0.48s.  Build: 1.14s.  Total: 1.61s.
[+] /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-pyflakes-1.6.0-7pgh7f6oulvjn5742ndl3wwxxb5knjd6
==> Installing py-flake8
==> Fetching https://github.com/PyCQA/flake8/archive/3.5.0.tar.gz
#=#=-#    #
==> Staging archive: /home/hartzell/spack/var/spack/stage/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/3.5.0.tar.gz
==> Created stage in /home/hartzell/spack/var/spack/stage/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x
==> Ran patch() for py-flake8
==> Building py-flake8 [PythonPackage]
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed py-flake8
  Fetch: 0.51s.  Build: 1.68s.  Total: 2.20s.
[+] /home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x
[hartzell@ip-10-96-1-107 spack]$ module avail

----------------------------------- /home/hartzell/spack/share/spack/lmod/linux-rhel7-x86_64/gcc/5.5.0 ------------------------------------
   ant/1.9.9-omlrprw                                  jemalloc/4.5.0-wstvcy3                 pigz/2.3.4-36hxluy
   aspell/0.60.6.1-cv4vtq2                     (L)    jq/1.5-bic4vte                         pigz/2.4-extsogi                    (D)
   aspell6-en/2017.01.22-0-yu7o7o2                    kbproto/1.0.7-hir45ah                  pixman/0.34.0-swmn2yi
   autoconf/2.69-s4blyuy                              libbsd/0.8.6-scvaat4            (L)    pkg-config/0.29.2-qzfyby7
   automake/1.16.1-xetjpin                            libevent/2.0.21-oworz2n         (L)    pkgconf/1.4.2-tj3xey2
   bats/0.4.0-lxk7inn                                 libffi/3.2.1-pw5ohbd                   postgresql/10.3-a6mkpr2
   bedtools2/2.27.1-2qbzyq3                           libgd/2.2.4-ap2zg2u                    py-argparse/1.4.0-py2.7-4btjajn     (L)
   bison/3.0.4-sx635a3                                libgtextutils/0.7-pdt42xp              py-configparser/3.5.0-py2.7-h3atyxv
   blat/35-xpihtic                                    libiconv/1.15-2ilmq2t           (L)    py-enum34/1.1.6-py2.7-aqs222q
   boost/1.59.0-ts6uehx                               libjpeg-turbo/1.5.90-itfncad           py-flake8/3.5.0-py2.7-gj6upym
   boost/1.66.0-we636om                        (D)    libpciaccess/0.13.5-dgawk42            py-igraph/0.7.0-py2.7-ggn3ikx
   bowtie2/2.3.4.1-py2.7-v6mncs5                      libpng/1.6.34-hnnn43a                  py-mccabe/0.6.1-py2.7-si5eqfs
   bumpversion/0.5.3-py2.7-lbns6i5                    libpthread-stubs/0.4-3p34u7s           py-pycodestyle/2.3.1-py2.7-xywxzk5
   byobu/5.123-r4dfdss                         (L)    libsigsegv/2.11-3z7yz43                py-pyflakes/1.6.0-py2.7-7pgh7f6
   bzip2/1.0.6-cwlahss                         (L)    libtermkey/0.18-roqnula                py-pygments/2.2.0-py2.7-6vm4e7y     (L)
   cairo/1.14.12-py2.7-zjbmafi                        libtiff/4.0.9-u7dnqy3                  py-pysocks/1.6.6-py2.7-kp3sjeg      (L)
   cmake/3.11.2-pfhpqaj                               libtool/2.4.6-qaxzdl4                  py-requests/2.14.2-py2.7-e2hgw2i    (L)
   curl/7.60.0-mnkg6zw                         (L)    libuv/1.9.0-bclb3lk                    py-requests/2.14.2-py3.6-glqs4cm    (D)
   datamash/1.3-anm232g                               libvterm/681-fbrynwq                   py-setuptools/39.0.1-py2.7-6jfae2n  (L)
   direnv/2.11.3-mljezxg                       (L)    libx11/1.6.5-eincepp                   py-setuptools/39.0.1-py3.6-rggcffx  (D)
   emacs/26.1-pfil3w2                          (L)    libxau/1.0.8-2ayc5m6                   py-wrapt/1.10.10-py3.6-fwyf5pv
   emboss/6.6.0-pugu3qt                               libxcb/1.13-hnz64ym                    python/2.7.15-5p2y647               (L)
   expat/2.2.5-wbviec6                         (L)    libxdmcp/1.1.2-gdzvdt6                 python/3.6.5-6zycwht                (D)
   fastx-toolkit/0.0.14-zhacqgh                       libxml2/2.9.8-hgfwbir           (L)    r/3.5.0-py2.7-l4sfzd3
   flex/2.6.3-s5sauhf                                 libxpm/3.5.12-ofi5ur5                  readline/7.0-ozyym5y                (L)
   font-util/1.3.1-2z4v4xo                            lmod/7.7.29-3npvlbw                    salmon/0.9.1-t4x5cuh
   fontconfig/2.12.3-w5tpwqh                          lua-bitlib/23-pg7bsgd                  samtools/1.8-s6lcmrd
   freetype/2.7.1-47u3rqc                             lua-lpeg/0.12.1-omhkbfe                snakemake/3.11.2-py3.6-nyccgx6
   gatk/4.0.4.0-py2.7-wwtpo5t                         lua-luafilesystem/1_6_3-ctf2hhi        spades/3.11.1-py2.7-o7zknyl
   gdbm/1.14.1-dimgxtn                         (L)    lua-luaposix/33.4.0-sdvyux2            sparsehash/2.0.3-pzaffc6
   gettext/0.19.8.1-vf4khxi                    (L)    lua-mpack/1.0.0-0-loqaqoj              sqlite/3.23.1-lksczst               (L)
   git/2.17.0-d4bs5gd                          (L)    lua/5.2.4-jfqqvao                      sra-toolkit/2.8.2-1-yz3lkea
   glib/2.56.0-py2.7-wuxvfoe                          lua/5.3.4-3p72nv3               (D)    star/2.5.3a-qyh4kaa
   go-bootstrap/1.4-bootstrap-20171003-npsfzii        m4/1.4.18-gtnxxgd                      tar/1.30-ah7apno                    (L)
   go/1.10.2-57iyhes                                  msgpack-c/3.0.1-va6mtyo                tcl/8.6.8-bejrvd3
   gobject-introspection/1.49.2-py2.7-vdhmdsa         multitail/6.4.2-we6rdnn                the-silver-searcher/2.1.0-w6sz7if   (L)
   gperf/3.0.4-3iwe7ry                                muscle/3.8.1551-auewnod                tk/8.6.8-wj6l527
   graphviz/2.40.1-aknrfsb                            nasm/2.13.03-3aegbhq                   tmux/2.7-7sgiyx2                    (L)
   harfbuzz/1.4.6-py2.7-jqvbeyc                       ncurses/6.1-b3yjgmv             (L)    tree/1.7.0-4ljcz4d                  (L)
   help2man/1.47.4-7mwi5m4                            neovim/0.2.2-fsktcto                   unibilium/1.2.0-blqrzcv
   htop/2.0.2-dgy7lmo                          (L)    numactl/2.0.11-abzq6la                 util-macros/1.19.1-znqyvtk
   htslib/1.8-osfrwmz                                 oniguruma/6.1.3-mo2fout                wget/1.19.1-vdiwgfq
   httpie/0.9.9-py2.7-wg4b3aa                  (L)    openmpi/3.1.0-mghowwk                  xcb-proto/1.13-cohzecg
   hwloc/1.11.9-4z4vwgb                               openssl/1.0.2n-66jppsd          (L)    xextproto/7.3.0-olpz76e
   icu4c/60.1-7iz3k4z                                 pango/1.41.0-py2.7-kn2hqdi             xproto/7.0.31-gghd2yt
   igraph/0.7.1-aer5rde                               parallel/20170322-x3lxkb6              xtrans/1.3.5-5fyl2pc
   igv/2.4.5-yhg5sc3                                  pcre/8.42-idvaazk               (L)    xz/5.2.4-xz3h7mc                    (L)
   inputproto/2.3.2-sokes2d                           pcre/8.42-jit-cayl7hu           (D)    zlib/1.2.11-56rgaos                 (L)
   intel-tbb/2018.2-qdnljpk                           perl/5.26.2-fe6gx5v             (L)
   jdk/8u172-b11-2rjw76x                              picard/2.18.3-glw5wdw

-------------------------------------- /home/hartzell/spack/share/spack/lmod/linux-rhel7-x86_64/Core --------------------------------------
   gcc/5.5.0-26dw7wa (L)

  Where:
   L:  Module is loaded
   D:  Default Module

Use "module spider" to find all possible modules.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".


[hartzell@ip-10-96-1-107 spack]$ module load py-flake8
[hartzell@ip-10-96-1-107 spack]$ module list

Currently Loaded Modules:
  1) gcc/5.5.0-26dw7wa         15) readline/7.0-ozyym5y                29) httpie/0.9.9-py2.7-wg4b3aa
  2) aspell/0.60.6.1-cv4vtq2   16) gdbm/1.14.1-dimgxtn                 30) pcre/8.42-idvaazk
  3) direnv/2.11.3-mljezxg     17) perl/5.26.2-fe6gx5v                 31) the-silver-searcher/2.1.0-w6sz7if
  4) ncurses/6.1-b3yjgmv       18) libiconv/1.15-2ilmq2t               32) libevent/2.0.21-oworz2n
  5) zlib/1.2.11-56rgaos       19) curl/7.60.0-mnkg6zw                 33) tmux/2.7-7sgiyx2
  6) emacs/26.1-pfil3w2        20) git/2.17.0-d4bs5gd                  34) tree/1.7.0-4ljcz4d
  7) libbsd/0.8.6-scvaat4      21) htop/2.0.2-dgy7lmo                  35) byobu/5.123-r4dfdss
  8) expat/2.2.5-wbviec6       22) sqlite/3.23.1-lksczst               36) py-enum34/1.1.6-py2.7-aqs222q
  9) openssl/1.0.2n-66jppsd    23) python/2.7.15-5p2y647               37) py-mccabe/0.6.1-py2.7-si5eqfs
 10) xz/5.2.4-xz3h7mc          24) py-pysocks/1.6.6-py2.7-kp3sjeg      38) py-pyflakes/1.6.0-py2.7-7pgh7f6
 11) libxml2/2.9.8-hgfwbir     25) py-requests/2.14.2-py2.7-e2hgw2i    39) py-pycodestyle/2.3.1-py2.7-xywxzk5
 12) bzip2/1.0.6-cwlahss       26) py-argparse/1.4.0-py2.7-4btjajn     40) py-configparser/3.5.0-py2.7-h3atyxv
 13) tar/1.30-ah7apno          27) py-pygments/2.2.0-py2.7-6vm4e7y     41) py-flake8/3.5.0-py2.7-gj6upym
 14) gettext/0.19.8.1-vf4khxi  28) py-setuptools/39.0.1-py2.7-6jfae2n



[hartzell@ip-10-96-1-107 spack]$ flake8
Traceback (most recent call last):
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/bin/flake8", line 11, in <module>
    load_entry_point('flake8==3.5.0', 'console_scripts', 'flake8')()
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-setuptools-39.0.1-6jfae2npd2ff3trjznsglbud6dzr2hwr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-setuptools-39.0.1-6jfae2npd2ff3trjznsglbud6dzr2hwr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2693, in load_entry_point
    return ep.load()
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-setuptools-39.0.1-6jfae2npd2ff3trjznsglbud6dzr2hwr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-setuptools-39.0.1-6jfae2npd2ff3trjznsglbud6dzr2hwr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/lib/python2.7/site-packages/flake8/main/cli.py", line 2, in <module>
    from flake8.main import application
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/lib/python2.7/site-packages/flake8/main/application.py", line 14, in <module>
    from flake8.main import options
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/lib/python2.7/site-packages/flake8/main/options.py", line 4, in <module>
    from flake8.main import vcs
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/lib/python2.7/site-packages/flake8/main/vcs.py", line 4, in <module>
    from flake8.main import mercurial
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-flake8-3.5.0-gj6upymrh6yq2yxzp64lsiztvk7wbx3x/lib/python2.7/site-packages/flake8/main/mercurial.py", line 7, in <module>
    import configparser
  File "/home/hartzell/spack/opt/spack/linux-rhel7-x86_64/gcc-5.5.0/py-configparser-3.5.0-h3atyxvuwid6gx76hxkcdmrt2u4dt3ez/lib/python2.7/site-packages/configparser.py", line 12, in <module>
    from backports.configparser import (
ImportError: No module named backports.configparser
[hartzell@ip-10-96-1-107 spack]$
```



Discussion:
This is due to the way `python`'s `import` semantics work.

Doing something like `from x.y import z` will essentially go through your PYTHONPATH (plus some additions, which I never am able to keep straight in my head) and look for the first folder that matches `x`, it then goes into that folder and looks for a file `y.py` and tries to import `z` from that (or a folder `y` and tries to import `z.py`). In your case the first `backports` folder that is found does not contain `configparser` (but probably `enum34`).

If you load `flake8` you also load its dependencies (via the autoload directive), but they still end up as different entries in `PYTHONPATH` (triggering the above condition). There is the possibility of modifying this search procedure, but I never understood the docs to it [see here](https://docs.python.org/2/library/site.html#module-site). 

There are a number of options that work:
- `spack activate py-flake8` would symlink flake8 into the `python` prefix and `load python` would give you a working `flake8` command
- `spack view` would give you a symlinked merged structure of flake8 that you could put on your PYTHONPATH directly

tl;dr: Python doesn't play nice with multi prefix installations of a namespace package 
Try running `spack modules loads -r py-flake8`.  Then make sure you import every module on that list.
@citibeth this won't work reliably as it depends on the order of the `module load`s. Either you will be able to import `backports.configparser` or `backports.enum34` but not both
Any way to fix this issue?

`spack module tcl loads -r py-flake8` then loading all output does not fix the problem.
you need to load the python package and do `spack activate py-flake8`, alternatively you can create a `spack view` of flake8 and put this on your PATH and co
`spack activate py-flake8` works!
I think (maybe) there is a better fix for this issue. The other backports.* packages usually co-exist nicely, but configparser won't. This seems to be because it does not have a `backports/__init__.py` file. If I add one the same as other backports.* packages use, then it co-exists fine. For example,

with modules loaded for py-backports-functools-lru-cache, py-backports-shutil-get-terminal-size and py-configparser, I get
```
>>> from backports import functools_lru_cache
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name functools_lru_cache
```
Without the py-configparser module loaded, I can do
```
>>> from backports import functools_lru_cache
>>> from backports import shutil_get_terminal_size
```

The `backports/__init__.py` for py-backports-functools-lru-cache contains one line
```
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
```
If I copy that into the backports/ directory for configparser, then I can do the following

```
>>> from backports import functools_lru_cache
>>> from backports import shutil_get_terminal_size
>>> from backports import configparser
```

I am not sure what is the best way to hack this into the package.py for py-configparser, but some sort of post-install thing sounds right. (And then prevail upon the maintainers of configparser to do it right)

Does all that make sense, or am I way off track?

Ah - just found my way to https://github.com/spack/spack/pull/4155 - you guys are all way ahead of me. 
Folks who are interested in this topic might want to follow (and/or push on) this PR in the configparser upstream: https://bitbucket.org/ambv/configparser/pull-requests/2/use-the-pkgutil-style-namespace-techniques/diff

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-configparser/package.py b/var/spack/repos/builtin/packages/py-configparser/package.py
--- a/var/spack/repos/builtin/packages/py-configparser/package.py
+++ b/var/spack/repos/builtin/packages/py-configparser/package.py
@@ -13,6 +13,7 @@ class PyConfigparser(PythonPackage):
     homepage = "https://docs.python.org/3/library/configparser.html"
     url      = "https://pypi.io/packages/source/c/configparser/configparser-3.5.0.tar.gz"
 
+    version('3.5.1', sha256='f41e19cb29bebfccb1a78627b3f328ec198cc8f39510c7c55e7dfc0ab58c8c62')
     version('3.5.0', 'cfdd915a5b7a6c09917a64a573140538')
 
     depends_on('py-setuptools', type='build')


Test patch: