This is not a reliable answer. But I will focus on a few problems associated with obtaining a solution. Most likely, the problem above is like a cancer caused by several factors that occur catastrophically together.
I have the same problem as the OP when trying to use my own Python packages provided by Cygwin on my Windows Vista machine. As a newbie in Python, I spent a few days getting this to work and understanding why it doesn't work. But all of my Google Fu have returned nothing but countless dead ends. So, I take it upon myself.
There are many reasons why Python may have problems with Cygwin, some of which you can do something, and some of which are outside of most people. What it boils down to include the following key issues:
Windows is a complete mess when it comes to file permissions, and Cygwin cannot handle Windows file permissions very well. So what you see in Cygwin is far from the whole story.
Windows is shamefully case-insensitive, which causes a lot of problems, especially when you need to (cross) compile everything that was originally developed in the * nix system (i.e. everything). In fact, if you try to extract any archive containing files whose names differ only in capitalization. (1.e. " makefile " vs " Makefile ", etc.) Files under Windows or Cygwin, you will lose everything except one of the files. in case of them. You need to enable case sensitivity in order to do something more than hello world * nix compilations.
Windows handles symbolic links completely different from Cygwin. And if your ZIP, TAR, etc. archives contain any symbolic links, they will be broken after extraction into the Windows environment.
The practice of sloppy code, where the developer did not test his creations in different environments properly or carefully set the correct file permissions for his *.tar.gz collections. Enabling the correct dependency specifications or indicating whether the binaries were statically linked, etc.
For more details and further problems (Win-Cygwin), see HERE .
At first I tried using Cygwin native Python without any additional packages and nstalling lxml using PIP and easy_install. Then I tried using Cygwin's own packages libxml2, libxslt and xml python, and I had the same problems.
First, after installing the static Windows binaries (as suggested elsewhere) I received this error:
File "/usr/lib/python2.7/site-packages/lxml-3.2.4-py2.7-cygwin-1.7.24-i686.egg/lxml/etree.py", line 6, in __bootstrap__ imp.load_dynamic(__name__,__file__) ImportError: Permission denied Aborted (core dumped)
Then I examined the file permissions and changed them with: chmod -R 755 /usr/lib/python2.7/
I took one more step to isolate the problem from the apparently missing file. And the inclusion of a detailed and diagnostic mode also did not help.
File "/usr/lib/python2.7/site-packages/lxml-3.2.4-py2.7-cygwin-1.7.24-i686.egg/lxml/etree.py", line 6, in __bootstrap__ imp.load_dynamic(__name__,__file__) ImportError: No such file or directory Aborted (core dumped)
HERE is the exact specification of the operator:
Download and initialize the module implemented as a dynamically loaded shared library and return its module object. If the module is already initialized, it will be initialized again. Re-initialization involves copying the __dict__ attribute of the cached module instance over the value used in the module cached in sys.modules. The pathname argument must point to a shared library. The name argument is used to create the name of the initialization function: an external C function called initname () is called in the shared library. The optional file argument is ignored. (Note: the use of shared libraries is very system dependent, and not all systems support it.)
So, I started reading on the lxml website , which clearly shows the dependencies of lxml on libxml2 and libxslt, and if they are not statically linked, they also depend on iconv and zlib. Therefore, you believe that you need to install all of these. Do not! Continue reading. But if you are going to build from sources (how easy_install can do this), you will need everything, including development header libraries: libxml2-devel, libxslt-devel . Elsewhere it is indicated that you also need Cython and install using:
easy_install lxml==dev
Dependencies are shown in this figure HERE :

So you think you can get away with something like:
STATIC_DEPS=true pip install lxml
But this is not done either. Probably because the libraries used to compile Cygwin Python should be the same as the libraries for compiling lxml. But I do not know. Please note that the lxml package belongs to Cygwin "1.7.24" . My Cygwin is already "1.7.25" and you can check it with uname -a . Then you can test your python static executable with file and ldd . Then you realize that this also depends on the C compiler used to create python / cygwin on Windows or * nix. After smelling the nightmare, I decided that building my own was not possible. So I tried installing Python libraries (as executables) designed for Windows Python. This did not work, since I had never installed Windows-based Python, and I met an error that the installed could not find Python in my registry. I could, of course, just extract the executable, but I would not know where to put the binaries without the installer. So I had a different idea ...
There are three possible solutions to make this work, as far as I can see.
An easy way to install the native Python Windows interpreter. You will lose some of Cygwin's own functions if you do not install them in the right place: /usr/lib/python2.7 and make sure Cygwin can find and use it. It also uses different file permissions, case sensitivity and character set (UTF-16LE) than Cygwin (UTF-8), potentially creating many other problems! Difficulty: Easy
Continue to crack Cygwin Python so that it works with the binary libraries used in (1). But this requires:
- a) Uninstall and remove all Cygwin Python packages except the simple Python interpreter.
- b) Remove all PIP and easy to install traces.
- c) Hacking the Windows registry to pretend that Python27 is installed:
- HKEY_LOCAL_MACHINE \ SOFTWARE \ Python \ PythonCore \ 2.7 \ InstallPath C: \ Python27 \
- HKEY_LOCAL_MACHINE \ SOFTWARE \ Python \ PythonCore \ 2.7 \ PythonPath C: \ Python27 \ Lib; C: \ Python27 \ DLL; C: \ Python27 \ Lib \ lib-tk
- HKEY_CLASSES_ROOT ...
- d) Install the Windows binary libraries.
- e) Everything else now, hopefully, will work with PIP or easy_install. Difficulty: Medium!
Doing it right by compiling Python and all libraries from scratch. Difficulty: hard!
I have successfully done (1), but I still think (2) is a more reasonable way to do this, but I have not tested it, so I do not consider this a good answer. BTW. Another quirk, I have to start the interpreter using python.exe -E to avoid annoying: " SyntaxError: invalid syntax " when returning!
Conclusion:
Apparently you don't need the libxml2 and libxslt python packages to use lxml! In my case, I need Scrapy, so I also had to install a few more packages.
$ pip.exe list cssselect (0.9.1) lxml (3.2.4) pip (1.4.1) pyOpenSSL (0.11) pywin32 (218) queuelib (1.1.1) Scrapy (0.20.0) setuptools (1.4.1) six (1.4.1) Twisted (13.2.0) w3lib (1.5) zope.interface (4.0.5) $ll /cygdrive/c/Python27/Lib/site-packages/ adodbapi cssselect isapi lxml OpenSSL pip pythonwin pywin32_system32 queuelib scrapy twisted w3lib win32 win32com win32comext zope cssselect-0.9.1-py2.7.egg-info lxml-3.2.4-py2.7.egg-info pip-1.4.1-py2.7.egg-info queuelib-1.1.1-py2.7.egg-info Scrapy-0.20.0-py2.7.egg-info six-1.4.1-py2.7.egg-info Twisted-13.2.0-py2.7.egg-info w3lib-1.5-py2.7.egg-info zope.interface-4.0.5-py2.7.egg-info PyWin32.chm setuptools-1.4.1-py2.7.egg pyOpenSSL-0.11-py2.7.egg-info pywin32-218-py2.7.egg-info easy-install.pth pywin32.pth setuptools.pth zope.interface-4.0.5-py2.7-nspkg.pth pythoncom.py six.py pythoncom.pyc six.pyc pythoncom.pyo pywin32.version.txt README.txt
Useful links: