如何在Windows计算机上的Python 3.4中安装lxml [英] How to install lxml in Python 3.4 on Windows machine

查看:310
本文介绍了如何在Windows计算机上的Python 3.4中安装lxml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经花了几个小时在这上面.我是Python的新手,所以看不到解决方案是什么.

我有Python 3.4,想使用需要 lxml .docx .

到目前为止,我完成的工作流程是:我进入了Python lxml 软件包安装程序页面,但是要知道我需要哪个版本却很令人困惑.我尝试了其中几个包含 34 数字的计算机,它们分别是 .exe .tar .我还尝试了pip install lxml3.4.4pip install lxml 3.4.4.他们都没有工作.

这是我执行pip install lxml时命令提示符的内容(它会自动抓取我下载的 lxml 3.4.4 ,然后打印出您在屏幕截图中看到的内容):

我在做什么错了,我能做些什么来修复它?和/或我需要从何处安装 lxml 的确切版本?我真的很沮丧,因为这是如此困难.谢谢

解决方案

lxml主页所述,它发生在您身上:

如果您无法通过我们发布的经过签名和测试的源代码在MS Windows系统上构建lxml,请考虑使用PyPI的二进制版本或Christoph Gohlke慷慨提供的非官方Windows二进制文件.

因此,您必须从用于Python扩展包的非官方Windows二进制文件中下载正确的wheel文件

<强>步骤1:下载相应的版本

根据您的计算机,您必须下载滚轮文件 lxml‑3.4.4‑cp34‑none‑win32.whl lxml‑3.4.4‑cp34‑none‑win_amd64. ,因为您要使用Python3.4的版本(即cp34中的 34 ).

<强>步骤2:打开cmd并导航到下载文件夹

我选择在管理员模式下打开cmd.但这可能对您来说不是必需的.

第3步:使用pip安装wheel文件

现在,您必须使用pip安装非官方的wheel文件.也许可以在安装wheel文件之前执行pip install pip --upgrade.但这对您来说也可能不是必需的.要进行安装,只需键入pip install <downloaded_file>.

或者正如cgohlke在他对您的问题的评论中提到的:如果您不能直接在cmd中执行pip install,则可以尝试以下操作:C:\Python34\python.exe -m pip install <downloaded_file>.当然,如果在其他位置安装了Python3.4,则必须编辑路径.

不要惊慌.如果您尝试安装错误的下载文件(例如 win32 而不是 amd64 ),则它不会破坏任何内容.应出现错误信息:<package name> is not a supported wheel on this platform.

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):

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.

So you have to download the right wheel file from Unofficial Windows Binaries for Python Extension Packages.

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 <downloaded_file>.

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 <downloaded_file>. 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: <package name> is not a supported wheel on this platform.

这篇关于如何在Windows计算机上的Python 3.4中安装lxml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆