4

I am aware that this question was asked many times. I have tried all known recipes but still have a problem.

So, I have created clear environment. Then pip install lxml with an error:

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w

In file included from src/lxml/lxml.etree.c:85:0:

/usr/include/python2.7/Python.h:8:22: fatal error: pyconfig.h: No such file or directory

compilation terminated.

Compile failed: command 'x86_64-linux-gnu-gcc' failed with exit status 1

creating tmp

cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitRwrJxg.c -o tmp/xmlXPathInitRwrJxg.o

/tmp/xmlXPathInitRwrJxg.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]

 main (int argc, char **argv) {

 ^

cc tmp/xmlXPathInitRwrJxg.o -lxml2 -o a.out

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/andriy/PROJECTS/delete/env/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-XHiH0Y/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zuYS3W-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/andriy/PROJECTS/delete/env/include/site/python2.7 failed with error code 1 in /tmp/pip-build-XHiH0Y/lxml
Traceback (most recent call last):
  File "/home/andriy/PROJECTS/delete/env/bin/pip", line 11, in <module>
sys.exit(main())
  File "/home/andriy/PROJECTS/delete/env/local/lib/python2.7/site-packages/pip/__init__.py", line 248, in main
    return command.main(cmd_args)
  File "/home/andriy/PROJECTS/delete/env/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 68: ordinal not in range(128)

I should say that I have successfully installed lxml on environment with Python3. Moreover, I have already been successfully installing lxml package to other environments earlier. But now something broke.

Any ideas how to solve it with Python2.7?

It is the second day of torments and I am about to reinstall my Ubuntu.

SOLUTION

Below Padraic Cunningham solved my problem. Log directly indicates that the problem is caused by the absence of file pyconfig.h in the system. It is the file of python-dev package. However, this package was already installed. So, it is naturally to assume that the package is corrupter and should be reinstalled with sudo apt-get install --reinstall python-dev libpython2.7-dev. Additionally libpython2.7-dev was reinstalled. After that file pyconfig.h appeared in correct place and pip install lxlm successfully installed the lxml package.

Andriy
  • 1,270
  • 3
  • 17
  • 35
  • 1
    Make sure you have `python-dev` installed – Padraic Cunningham Mar 15 '16 at 17:25
  • Hope somebody will come up with some unknown recipe. – Stop harming Monica Mar 15 '16 at 17:27
  • @PadraicCunningham It is already installed. – Andriy Mar 15 '16 at 18:02
  • 1
    So `ls /usr/include/python2.7/ | grep pyconfig` returns something? – Padraic Cunningham Mar 15 '16 at 18:20
  • @PadraicCunningham No, it doesn't... Should it? But `dpkg --get-selections | grep python-dev` among others returns me `libpython-dev:amd64 install` and `python-dev install` – Andriy Mar 15 '16 at 18:31
  • 1
    Yes, it should be there, just to verify `sudo apt-get install libpython2.7-dev` – Padraic Cunningham Mar 15 '16 at 18:34
  • 2
    omg... I suppose, I know what caused the problem. Two weeks ago I was trying to delete all `*.pyc` files. I suppose, I have deleted also files containing `pyc` in their names and `pyconfig` was one of them. – Andriy Mar 15 '16 at 18:42
  • @PadraicCunningham Unfortunately, `sudo apt-get install libpython2.7-dev` was unsuccessful. System answered **libpython2.7-dev is already the newest version.** Could you help me now, when we know what exactly caused the problem? – Andriy Mar 15 '16 at 18:46
  • 3
    try `sudo apt-get --reinstall install python-dev libpython2.7-dev` – Padraic Cunningham Mar 15 '16 at 18:47
  • 1
    http://packages.ubuntu.com/trusty/amd64/libpython2.7-dev/filelist you can see the `pyconfig.h` file listed so if it installed it has to be somewhere, what does `locate pyconfig.h` return? – Padraic Cunningham Mar 15 '16 at 18:56
  • @PadraicCunningham Reinstall of `python-dev` and `libpython2.7-dev` solved the problem! I managed to install `lxml` in environment! Thank you! Please make your comment as an answer I could mark it as a solution. – Andriy Mar 15 '16 at 22:00

1 Answers1

1

u can try it:

sudo apt-get install python-dev libxml2-dev libxslt1-dev zlib1g-dev

qvpham
  • 1,896
  • 9
  • 17