-1

I have been trying to use pip install to install the cython and lxml packages under Python3.8 on Cygwin. However, this repeatedly fails with incomprehensible errors ranging from python errors to gcc header files not found, even though they are there.

Because lxml depends on Cython, we need to make sure we have that working first. Unfortunately Cygwin's python3.8 doesn't yet support cython, it seems. So we are told to download and use the wheel from here.

pip install Cython-0.29.13-cp38-cp38-win32.whl

# This fails with:
#ERROR: Cython-0.29.13-cp38-cp38-win32.whl is not a supported wheel on this platform.

# Instead use:
pip install Cython --install-option="--no-cython-compile"
# OK!

Now let's try to install the lxml package.

pip install lxml
# FAIL

STATIC_DEPS=true pip3 install lxml
# FAIL

Let's check that Python.h exists:

# find /usr/include -type f -name "Python.h"
/usr/include/python2.7/Python.h
/usr/include/python3.6m/Python.h
/usr/include/python3.8/Python.h

Ok...

So what is the problem?


Related Issues:

not2qubit
  • 14,531
  • 8
  • 95
  • 135

2 Answers2

0

The only thing that seemed to work, is downloading the sources and install from there. The procedure is this:

git clone https://github.com/lxml/lxml.git lxml
cd lxml
python3.8 setup.py install

pip-date |grep lxml
# lxml     2019-10-15  16:12:05    4.5.0a0   egg    sdist   sys

pip list |grep lxml
# lxml   4.5.0a0

It is also possible that the reason compilation fails, is because there are several gcc compilers installed. So although I have not tested this yet, you may need to specify which compiler the (python?) environment should use.

First find what compilers are in your path:

# ls -1 /usr/bin/*gcc.exe
/usr/bin/gcc.exe
/usr/bin/i686-w64-mingw32-gcc.exe
/usr/bin/x86_64-pc-cygwin-gcc.exe
/usr/bin/x86_64-w64-mingw32-gcc.exe

Then try to export the right one to the CC environment variable with (for example):

export CC=/usr/bin/x86_64-w64-mingw32-gcc.exe

Now test the pip install xxx again and see if it helped. If it did, add the above line to your ~/.bashrc file.

not2qubit
  • 14,531
  • 8
  • 95
  • 135
0

You can install it using the "setup-x86_64.exe" program as described in the official Cygwin documentation (https://cygwin.com/install.html). The setup program can be used to perform a fresh install or to update an existing installation. Steps to achieve this:

  1. Run the setup-x86_64.exe program
  2. Choose to install from Internet
  3. You can install for all users or just you
  4. Leave the Local Package Directory as is
  5. Choose Direct Connection
  6. Use the https://mirrors.163.com
  7. Then, change the view to to Full and search for lxml for your python version

Image showing how to search for lxml