Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
310 views
in Technique[技术] by (71.8m points)

python - Installing lxml, libxml2, libxslt on Windows 8.1

After additional exploration, I found a solution to installing lxml with pip and wheel. Additional comments on approach welcomed.

I'm finding the existing Python documentation for Linux distributions excellent. For Windows... not so much. I've configured my Linux system fine but I need some help getting a Windows 8.1 tablet ready as well.

My project requires the lxml module for Python 3.4. I've found many tutorials on how to install lxml but each has failed.

https://docs.python.org/3/installing/ I've downloaded the "get-pip.py" and successfully ran it from the Windows cmd line with the result:

Requirement already up-to-date: pip in c:python34libsite-packages

So I don't think that I have a "pip" problem. From there I've run the following from the Windows cmd line:

python -m pip install lxml

A long list of commands scroll through but there are a couple of lines that appear to be errors that I'm unable to resolve.

  ERROR: b"'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 **

and

Failed building wheel for lxml

And the last part, all in red

Command "C:Python34python.exe -c "import setuptools, tokenize;__file__='C:\Users\Owner\AppData\Local\Temp\pip-build-ya3n6wkd\lxml\setup.py';exec(compi
le(getattr(tokenize, 'open', open)(__file__).read().replace('
', '
'), __file__, 'exec'))" install --record C:UsersOwnerAppDataLocalTemppip-ytybzl9l-r
ecordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersOwnerAppDataLocalTemppip-build-ya3n6wkdlxml

Any assistance in understanding how this should work, or what I'm doing wrong would be greatly appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was able to fix the installation with the following steps. I hope others find this helpful.

My installation of "pip" was working fine before the problem. I went to the Windows command line and made sure that "wheel" was installed.

C:Python34>python -m pip install wheel
Requirement already satisfied (use --upgrade to upgrade): wheel in c:python34libsite-packages

After that I downloaded the lxml file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml and placed it in my python directory "C:Python34"

In that directory I ran the following:

C:Python34>python -m pip install lxml-3.4.4-cp34-none-win32.whl

The results were:

Processing c:python34lxml-3.4.4-cp34-none-win32.whl
Installing collected packages: lxml
Successfully installed lxml-3.4.4

I opened PyCharm and lxml module was available. I was able to execute the code without problem.

What I learned (though this may be corrected by others more knowledgeable)

  1. Need to install the desired module (as a "*.whl" file) using pip and wheel.
  2. Using Dropbox to share a code folder with different PyCharm installations causes confusion for the "workspace.xml" file. The two computers kept writing over each other, messing up the installation paths.

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...