Inky PHAT: Cannot import name InkyPHAT

Hi - I recently got an Inky PHAT and am having one or two problems with it, I’ve had the same thing on both a Pi A+ and a regular 3B. Both have had clean installs of the latest full raspbian and all updates installed.

I used the one line installer from the getting started guide, which ran OK as far as the below…

In file included from src/lxml/etree.c:662:0:
  src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
   #include "libxml/xmlversion.h"
                                 ^
  compilation terminated.
  Compile failed: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
  creating tmp
  cc -I/usr/include/libxml2 -c /tmp/xmlXPathInit0Mq_8R.c -o tmp/xmlXPathInit0Mq_8R.o
  /tmp/xmlXPathInit0Mq_8R.c:1:26: fatal error: libxml/xpath.h: No such file or directory
   #include "libxml/xpath.h"
                            ^
  compilation terminated.
  *********************************************************************************
  Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
  *********************************************************************************
  error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for lxml
  Running setup.py clean for lxml
Failed to build lxml
Installing collected packages: slacker, lxml, unidecode, wikiquotes
  Running setup.py install for lxml ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ryeINr/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-Fh4orF-record/install-record.txt --single-version-externally-managed --compile:
    Building lxml version 4.2.5.
    Building without Cython.
    ERROR: /bin/sh: 1: xslt-config: not found
    
    ** make sure the development packages of libxml2 and libxslt are installed **
    
    Using build configuration of libxslt
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-2.7
    creating build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/sax.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/builder.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/_elementpath.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/__init__.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/cssselect.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/ElementInclude.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/doctestcompare.py -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/usedoctest.py -> build/lib.linux-armv7l-2.7/lxml
    creating build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.linux-armv7l-2.7/lxml/includes
    creating build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/builder.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/diff.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/clean.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/defs.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.linux-armv7l-2.7/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.linux-armv7l-2.7/lxml/html
    creating build/lib.linux-armv7l-2.7/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.linux-armv7l-2.7/lxml/isoschematron
    copying src/lxml/etree.h -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/etree_api.h -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/lxml.etree.h -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.linux-armv7l-2.7/lxml
    copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/__init__.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/c14n.pxd -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.linux-armv7l-2.7/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.linux-armv7l-2.7/lxml/includes
    creating build/lib.linux-armv7l-2.7/lxml/isoschematron/resources
    creating build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/rng
    creating build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl
    creating build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-armv7l-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.linux-armv7l-2.7
    creating build/temp.linux-armv7l-2.7/src
    creating build/temp.linux-armv7l-2.7/src/lxml
    arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-Ub3vap/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/etree.c -o build/temp.linux-armv7l-2.7/src/lxml/etree.o -w
    In file included from src/lxml/etree.c:662:0:
    src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
     #include "libxml/xmlversion.h"
                                   ^
    compilation terminated.
    Compile failed: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    cc -I/usr/include/libxml2 -c /tmp/xmlXPathInit_St_1z.c -o tmp/xmlXPathInit_St_1z.o
    /tmp/xmlXPathInit_St_1z.c:1:26: fatal error: libxml/xpath.h: No such file or directory
     #include "libxml/xpath.h"
                              ^
    compilation terminated.
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    *********************************************************************************
    error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ryeINr/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-Fh4orF-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ryeINr/lxml/
python3-wikiquotes is required
Installing python3-wikiquotes...
E: Unable to locate package python3-wikiquotes
Apt failed to install python3-wikiquotes!
Falling back on pypi...
Requirement already satisfied: wikiquotes in /usr/local/lib/python3.5/dist-packages
Requirement already satisfied: lxml in /usr/local/lib/python3.5/dist-packages (from wikiquotes)
Requirement already satisfied: bs4 in /usr/local/lib/python3.5/dist-packages (from wikiquotes)
Requirement already satisfied: slacker in /usr/local/lib/python3.5/dist-packages (from wikiquotes)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from wikiquotes)
Requirement already satisfied: unidecode in /usr/local/lib/python3.5/dist-packages (from wikiquotes)
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.5/dist-packages (from bs4->wikiquotes)

Downloading examples and documentation...

The examples directory already exists on your system!
We've backed them up as examples-backup, just in case you've changed anything!

Resources for your Inky pHAT & wHAT were copied to
/home/pi/Pimoroni/inky

Finalising Install...


Some packages could not be installed, review the output for details!

Now when I try to run name-badge.py I get the error:

`

ImportError:Cannot import name InkyWHAT

`

Any ideas? I’ve tried manually installing inky but this hangs partway through on one of the wheels - getting confused now with the different versions - Thanks!

I see all kinds of “Failed” in the install screenshot you posted? Did you have Internet access? Are you behind a firewall like maybe at a work place?

Nope just in a regular house - I might give it another go with the ethernet cable just in case the wi-fi’s a bit weak. Thanks!

Just tried with ethernet, getting exactly the same error. Odd!

Which Inky pHat is it, and which command line are you running?

I ask because I see the “Cannot import name InkyWHAT”. If it is in fact an Inky Phat and not the Inky wHAT, your running the wrong installer script.

It’s the most recent one, a Red - the WHAT error was because I was trying to run the logo.py script and it imports both, WHAT first - apologies though I just rebooted the Pi and now the name badge and logo scripts are working - really have no idea what went on there. Thanks for the support!

Ok, good that its working. IMHO It’s good practice to reboot after running an installer script.
I asked which one because in the thread title you stated Inky Phat, but the error indicated you were running examples (code) for the Inky wHAT I was thinking you might have run the wrong installer my mistake.

Your good to go now though. Have fun. =)

1 Like

Was just too eager to get stuck in! Good advice.

Been there done that. ;)

Hi there,

Pretty new to this stuff and trying to install the InkyPHAT and am getting the same ImportError: cannot import name InkyPHAT

Not sure what/where I could find a report to give you guys more info, but hopefully someone could help?

Thanks

Did you run the one line installer for the Inky you have.