Question

I have Python 2.7 and I was trying to use PyQuery, so for a test I just typed "import PyQuery" and I got an error:

Traceback (most recent call last):
  File "C:\Users\Jacob\Documents\dupes.py", line 1, in <module>
    import pyquery
  File "C:\Python27\lib\site-packages\pyquery-1.2.1-py2.7.egg\pyquery\__init__.py", line 12, in <module>
    from .pyquery import PyQuery
  File "C:\Python27\lib\site-packages\pyquery-1.2.1-py2.7.egg\pyquery\pyquery.py", line 8, in <module>
    from lxml import etree
ImportError: No module named lxml

So I went to the command prompt and tried to install lxml, but I got this:

Building lxml version 2.3.5.
Building without Cython.
ERROR: 'xslt-config' is not recognized as an internal or external command,
operable program or batch file.

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
error: Setup script exited with error: Unable to find vcvarsall.bat

I don't really understand what's wrong or what I should do...can someone help?

Thanks.

EDIT:

In response to the comment, I used easy install...

Was it helpful?

Solution

From installation instructions of lxml:

easy_install --allow-hosts=lxml.de,*.python.org lxml

On MS Windows, the above will install the binary builds that we provide. If there is no binary build of the latest release yet, please search PyPI for the last release that has them and pass that version to easy_install like this:

easy_install --allow-hosts=lxml.de,*.python.org lxml==2.2.2

[edit]

Ok, 2.2.2 was en example. I went and looked for you, try:

easy_install --allow-hosts=lxml.de,*.python.org lxml==2.3

OTHER TIPS

Unless your Windows environment is properly set (proper Visual Studio version for your Python version and all that), you should download binary eggs and install them. I know setuptools (and possibly distribute) support installing binary executable packages on Windows (the distutils-based executables only - the ones with the blue background and old dot-matrix Python logo; sorry, but I haven't done Python on Windows in a couple months). Pip doesn't (probably what you are/were using).

But to answer your question, the batch file vcvarsall.bat is used to set the environment variables necessary for building Visual Studio projects/solutions (and generally using any Visual Studio tools) from the command line. It's not in your PATH by default, and since pip is trying to use it to build lxml properly, it fails.

My advice: unless you know how to use Visual Studio command line tools, you're much better off using binary packages on Windows.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top