python3安装不了lxml_如何在Windows计算机上的Python 3.4中安装lxml

1586010002-jmsa.png

I've been spending hours on this. I'm new to Python and can't see what the solution may be.

I have Python 3.4 and want to work with .docx, which requires lxml.

The workflow I've done so far is: I go to the Python lxml package installer page, but it's quite confusing to know which version I need. I tried with several of them that contained the 34 numbers, both .exe and .tar. I also tried pip install lxml3.4.4 and pip install lxml 3.4.4. None of them worked either.

This is what the command prompt says when I did pip install lxml (it automatically grabs the lxml 3.4.4 I've downloaded and then prints what you can see in the screenshot):

NduD2.png

What am I doing wrong and what can I do to repair it? And/or what exact version of lxml do I need to install from where? I am really discouraged that this is so difficult. Thanks

解决方案

As said at the lxml homepage, it happened to you:

If you fail to build lxml on your MS Windows system from the signed and tested sources that we release, consider using the binary builds from PyPI or the unofficial Windows binaries that Christoph Gohlke generously provides.

Step 1: Download appropriate version

Depending on your machine you have to download the wheel file lxml‑3.4.4‑cp34‑none‑win32.whl or lxml‑3.4.4‑cp34‑none‑win_amd64.whl, because you want the version for Python3.4 (that's the 34 in cp34).

Step 2: Open cmd and navigate to the download folder

I have chosen to open the cmd in administrator mode. But this is probably not necessary for you.

Step 3: Install wheel file with pip

Now you have to install the unofficial wheel file with pip. Maybe you can do pip install pip --upgrade before you install the wheel file. But this is probably also not necessary for you. To do the installation, just type pip install .

Or as cgohlke mentioned in his comment to your question: If you can't do pip install in cmd directly, this is what you can try: C:\Python34\python.exe -m pip install . You have to edit the path if Python3.4 is installed elsewhere, of course.

Don't panic. If you try to install the wrong downloaded file (e. g. win32 instead of amd64), it shouldn't break anything. An error message should occur: is not a supported wheel on this platform.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值