0

Condition: unable to troubleshoot failed installation of the library/module pywfdb from pip
Differential conditions: failed dependenciens of pywfdb
Exclude: upstart/systemd design bugs with runit in Ubuntu here since Ubuntu >=14.10
Settings

  • PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  • PYTHONPATH blank in $HOME/.bashrc

Work flow for dependencies and dirty installation with much logs

  • Edwinksl's proposal: sudo apt-get install python-pyrex

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following NEW packages will be installed:
    python-pyrex
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.         2 not fully installed or removed.
    Need to get 181 kB of archives.
    After this operation, 996 kB of additional disk space will be used.
    Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-pyrex all 0.9.8.5-2.1ubuntu1 [181 kB]
    Fetched 181 kB in 0s (356 kB/s)      
    Selecting previously unselected package python-pyrex.
    (Reading database ... 434011 files and directories currently installed.)
    Preparing to unpack .../python-pyrex_0.9.8.5-2.1ubuntu1_all.deb ...
    Unpacking python-pyrex (0.9.8.5-2.1ubuntu1) ...
    Processing triggers for doc-base (0.10.7) ...
    Processing 1 added doc-base file...
    Registering documents with scrollkeeper...
    Processing triggers for man-db (2.7.5-1) ...
    Setting up runit (2.1.2-3ubuntu1) ...
    - -
    Setting up python-pyrex (0.9.8.5-2.1ubuntu1) ...
    - -
    
  • Work flow with dirty installation to not clean up after the install, to see what pip was trying to do sudo -H pip install --no-clean pywfdb

    Collecting pywfdb
      Using cached pywfdb-0.1.1.zip
    Building wheels for collected packages: pywfdb
      Running setup.py bdist_wheel for pywfdb ... error
      Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_Tu9q1/pywfdb/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpemnpLdpip-wheel- --python-tag cp27:
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-2.7
      creating build/lib.linux-x86_64-2.7/pywfdb
      copying pywfdb/__init__.py -> build/lib.linux-x86_64-2.7/pywfdb
      copying pywfdb/ecgcodes.py -> build/lib.linux-x86_64-2.7/pywfdb
      package init file 'example/__init__.py' not found (or not a regular file)
      creating build/lib.linux-x86_64-2.7/pywfdb/example
      copying example/readinfo.py -> build/lib.linux-x86_64-2.7/pywfdb/example
      copying example/plot.py -> build/lib.linux-x86_64-2.7/pywfdb/example
      running build_ext
      building 'pywfdb._pywfdb' extension
      creating build/temp.linux-x86_64-2.7
      creating build/temp.linux-x86_64-2.7/pywfdb
      creating build/temp.linux-x86_64-2.7/wfdb-10.4.4
      creating build/temp.linux-x86_64-2.7/wfdb-10.4.4/lib
      x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I./wfdb-10.4.4/lib -I/usr/include/python2.7 -c pywfdb/_pywfdb.c -o build/temp.linux-x86_64-2.7/pywfdb/_pywfdb.o -Wno-uninitialized -Wno-unused
      pywfdb/_pywfdb.c:15:22: fatal error: ecgcodes.h: No such file or directory
      #include "ecgcodes.h"
                            ^
      compilation terminated.
      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
      ----------------------------------------
      Failed building wheel for pywfdb
      Running setup.py clean for pywfdb
      Failed to build pywfdb
     Installing collected packages: pywfdb
     Running setup.py install for pywfdb ... error
        Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_Tu9q1/pywfdb/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gdKcwF-record/install-record.txt --single-version-externally-managed --compile:
        running install
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-2.7
        creating build/lib.linux-x86_64-2.7/pywfdb
        copying pywfdb/__init__.py -> build/lib.linux-x86_64-2.7/pywfdb
        copying pywfdb/ecgcodes.py -> build/lib.linux-x86_64-2.7/pywfdb
        package init file 'example/__init__.py' not found (or not a regular file)
        creating build/lib.linux-x86_64-2.7/pywfdb/example
        copying example/readinfo.py -> build/lib.linux-x86_64-2.7/pywfdb/example
        copying example/plot.py -> build/lib.linux-x86_64-2.7/pywfdb/example
        running build_ext
        building 'pywfdb._pywfdb' extension
        creating build/temp.linux-x86_64-2.7
        creating build/temp.linux-x86_64-2.7/pywfdb
        creating build/temp.linux-x86_64-2.7/wfdb-10.4.4
        creating build/temp.linux-x86_64-2.7/wfdb-10.4.4/lib
        x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I./wfdb-10.4.4/lib -I/usr/include/python2.7 -c pywfdb/_pywfdb.c -o build/temp.linux-x86_64-2.7/pywfdb/_pywfdb.o -Wno-uninitialized -Wno-unused
        pywfdb/_pywfdb.c:15:22: fatal error: ecgcodes.h: No such file or directory
        #include "ecgcodes.h"
                             ^
        compilation terminated.
        error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
        ----------------------------------------
        Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_Tu9q1/pywfdb/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gdKcwF-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_Tu9q1/pywfdb/
    

Open

  • Why Failed building wheel for pywfdb?
  • Why the following error reproduced here from the full log?

    Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_Tu9q1/pywfdb/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gdKcwF-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_Tu9q1/pywfdb/
    

Troubleshooting Methods

Pip local modules where you see no wfdb found got by Adam's first command set

" https://stackoverflow.com/a/23885252/54964 "
['adium-theme-ubuntu==0.3.4', 'alabaster==0.7.8', 'auxlib==0.0.37', 'babel==2.3.4', 'backports-abc==0.4', 'backports.shutil-get-terminal-size==1.0.0', 'backports.ssl-match-hostname==3.5.0.1', 'beautifulsoup4==4.4.1', 'ccsm==0.9.12.2', 'certifi==2016.2.28', 'chardet==2.3.0', 'compizconfig-python==0.9.12.2', 'configparser==3.5.0', 'cycler==0.10.0', 'decorator==4.0.9', 'docutils==0.12', 'duplicity==0.7.6', 'entrypoints==0.2.2', 'enum34==1.1.6', 'functools32==3.2.3.post2', 'futures==3.0.5', 'html5lib==0.999', 'httplib2==0.9.1', 'imagesize==0.7.1', 'ipykernel==4.3.1', 'ipyparallel==5.0.1', 'ipython-genutils==0.1.0', 'ipython==4.2.0', 'ipywidgets==5.1.5', 'jinja2==2.8', 'jsonschema==2.5.1', 'jupyter-client==4.2.2', 'jupyter-core==4.1.0', 'lockfile==0.12.2', 'lxml==3.5.0', 'markupsafe==0.23', 'matlab-kernel==0.9.6', 'matplotlib==1.5.1', 'metakernel==0.13.0', 'mistune==0.7.2', 'nbconvert==4.2.0', 'nbformat==4.0.1', 'nose==1.3.7', 'notebook==4.2.1', 'numpy==1.11.0', 'pandas==0.18.1', 'path.py==8.2.1', 'pathlib2==2.1.0', 'pdfshuffler==0.6.0', 'pexpect==4.1.0', 'pickleshare==0.7.2', 'pillow==3.1.2', 'pip==8.1.2', 'ptyprocess==0.5.1', 'pycosat==0.6.1', 'pycurl==7.43.0', 'pygments==2.1.3', 'pygobject==3.20.0', 'pyicu==1.9.2', 'pymatbridge==0.5.2', 'pymysql==0.7.2', 'pyparsing==2.1.4', 'pypdf==1.13', 'python-dateutil==2.5.3', 'python-djvulibre==0.7', 'pytz==2016.4', 'pyxdg==0.25', 'pyyaml==3.11', 'pyzmq==15.2.0', 'qtconsole==4.2.1', 'requests==2.10.0', 'scour==0.32', 'setuptools==22.0.5', 'simplegeneric==0.8.1', 'singledispatch==3.4.0.3', 'six==1.10.0', 'snowballstemmer==1.2.1', 'sphinx==1.4.3', 'subprocess32==3.2.6', 'terminado==0.6', 'testpath==0.3', 'tornado==4.3', 'traitlets==4.2.1', 'unity-lens-photos==1.0', 'wheel==0.29.0', 'widgetsnbextension==1.2.3']

Unsuccessful test commands for the info of the package/module/library

  • pip search wfdb gives pywfdb (0.1.1) - Python interface to WFDB library so I expect it to include also the module which you can import.
  • find /usr/local/lib/python2.7/dist-packages -name '*wfdb*' returns blank.
  • pip list |grep wfdb returns blank.
  • pip show pywfdb returns blank.

Test code which shows that the module is not found

" http://www.pybytes.com/pywfdb/ "
import pywfdb

Trying to search the module

  • Not installed as normal python package because not in /usr/lib/python<version>/site-packages as described here; I searched all directories (/usr/local/lib/python2.7/ and /usr/local/lib/python3.5/).

  • Not in dist-packages based on the answer. Command ls /usr/local/lib/python2.7/dist-packages/ | grep wfdb returns blank.

  • >>> import site; site.getsitepackages() gives the output

    ['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
    

    Blank outputs for ls /usr/local/lib/python2.7/dist-packages | grep wfdb and ls /usr/lib/python2.7/dist-packages | grep wfdb.

System: Linux Ubuntu 16.04 64 bit
Linux kernel: 4.6
Linux kernel options: wl
Hardware: Macbook Air 2013-mid
Python: 2.7.11+
Pip: latest (8.1.2) pip install --upgrade pip returns Requirement already up-to-date: pip in /home/masi/.local/lib/python2.7/site-packages
Latest pip modules: pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U done before
Bash: 4.3.46(1)-release (x86_64-pc-linux-gnu)

Léo Léopold Hertz 준영
  • 6,788
  • 29
  • 91
  • 193
  • 1
    Can you get the package if you install it inside a `virtualenv`? In a virtualenv you're free from ubuntu's package manager. Also `find /usr/local/lib/python2.7/dist-packages -name '*wfdb*'` should be more effective than plain `ls` – grochmal Jul 10 '16 at 17:18
  • 2
    Are you sure it installed successfully? – leekaiinthesky Jul 10 '16 at 17:20
  • 2
    Well, if tests do not pass in `setup.py` it will not install the module. `Pyrex` is a wrapper for C code, and the underlying `wfdb` library is in C code, therefore i suspect you do not have `wfdb` installed. – grochmal Jul 10 '16 at 17:34
  • You can follow either the installation guide provided by [pywfdb](http://www.pybytes.com/pywfdb/) or the one provided by [wfdb itself](https://www.physionet.org/physiotools/wfdb-linux-quick-start.shtml) – grochmal Jul 10 '16 at 17:37
  • 1
    @Masi Try `sudo apt install python-pyrex` and then `sudo -H pip install pywfdb` and see if that resolves the `ImportError`. – edwinksl Jul 10 '16 at 17:39
  • 2
    Stop ignoring errors! You created a snowball of errors that you cannot get out off. Your first problem is that *there is something wrong with upstart*. Fix that first, then update `apt-get` as far as you can and test if it works, only then go for installing new stuff. – grochmal Jul 10 '16 at 17:53
  • You need a running `dpkg`, without a running `dpkg`/`apt-get` your system is neigh useless. And i mean the part about "ignoring errors" until you have `Pyrex` and `wfdb` you will not be able to install `pywfdb`. Errors must be fixed bottom up, otherwise they will keep biting. – grochmal Jul 10 '16 at 18:05
  • 1
    Fair enough, it is worth a try. You can setup a `virtualenv` and install `Pyrex` and then try `pywfdb` (I assume you are 100% you have the `wfdb` lib installed). Yet, `Pyrex` must be compiled, if the compiler tree is not OK you're dead in boots and your only option is to fix `dpkg`. Also, *ul.SE* will suggest in a moment to move this to `/dev/chat`. – grochmal Jul 10 '16 at 20:19

2 Answers2

1

Masi,

finally I could run this library. My steps are as follows:

  1. download wfdb-10.5.24 from physionet website
  2. compile and install
  3. cd /usr/include
    sudo ln -s /usr/local/include/wfdb wfdb
    
  4. sudo apt-get install python-pyrex
  5. open this file by any text editor pywfdb/_pywfdb.c and replace these lines into:

    #include <wfdb/ecgcodes.h>
    #include <wfdb/ecgmap.h>
    #include <wfdb/wfdb.h>
    
  6. in setup.py file on lines 14 and 15 put the path of wfdb-10.5.24/lib directory

  7. python setup.py install

Linux: Ubuntu 16.04

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
xenith
  • 11
  • 1
1

Expanding on the above answer, since it pointed me in the right direction but skipped a few keysteps.

Disclaimer: I am not an experienced Linux user, but this worked on a clean DigitalOcean Ubuntu install.

  1. depencies (in case you haven't already):

    • $ sudo apt-get install python-dev python-pip python-pyrex unzip
  2. download WFDB source from www.physionet.org/physiotools/wfdb.tar.gz

    • extract to ~/
  3. Compile and install the WFDB C library

    • @~/wfdb-10.5.24/wfdb$ ./configure --without-netfiles --static --static_only
    • (the tutorial at http://www.pybytes.com/pywfdb/ says you need to use --without-netfiles switch; i didn't have any problems by not using it, but couldn't get the python wrapper to import from physionet and so you should)
    • @~/wfdb-10.5.24/wfdb$ sudo make install
    • @~/wfdb-10.5.24/wfdb$ make check
  4. download pywfdb source from pypi.python.org/packages/source/p/pywfdb/pywfdb-0.1.1.zip

    • unzip to ~/
  5. edit ~/pywfdb-0.1.1/pywfdb/_pywfdb.c

    • replace \*.h with <wfdb/*.h> in lines 15, 16, 17
  6. edit ~/pywfdb-0.1.1/setup.py

    • replace ./wfdb-10.4.4/ with /home/username/wfdb-10.5.24/ in lines 14, 15 (or wherever you extracted it to; the ~/ alias did not work for me)
  7. @/usr/include$ ln -s /usr/local/include/wfdb wfdb

  8. @~/pywfdb$ sudo python setup.py install

  9. (above answer ends here, but I needed this extra step to actually import the lib within python) @/usr/lib/python2.7/dist-packages$ ln -s /usr/local/lib/python2.7/dist-packages/pywfdb pywfdb

Monstah
  • 126
  • 2