Python - 如何安装 xlutils?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16176864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 21:57:31  来源:igfitidea点击:

Python - How can I install xlutils?

pythonexcel

提问by Chelonian

I am using Python 2.5 (and need to stay with that) and have already downloaded xlrd 0.8.0 and xlwt 0.7.2, and they both seem to be working OK.

我正在使用 Python 2.5(并且需要继续使用)并且已经下载了 xlrd 0.8.0 和 xlwt 0.7.2,它们似乎都运行正常。

I will be needing to read from and write to Excel spreadsheets, and so believe I will need to add xlutils as well. The problem is, I can't install it so far.

我将需要读取和写入 Excel 电子表格,因此我相信我还需要添加 xlutils。问题是,到目前为止我无法安装它。

I have pip and tried the simple:

我有 pip 并尝试了简单的:

pip install xlutils

That ran and downloaded xlutils, but got hung up with:

运行并下载了 xlutils,但被挂断了:

Downloading/unpacking xlutils
  Downloading xlutils-1.6.0.tar.gz (54Kb): 54Kb downloaded
  Running setup.py egg_info for package xlutils
Downloading/unpacking xlrd>=0.7.2 (from xlutils)
  Downloading xlrd-0.9.2.tar.gz (167Kb): 167Kb downloaded
  Running setup.py egg_info for package xlrd
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "C:\Python25\Lib\site-packages\xlutils-1.6.0\build\xlrd\setup.py", li
ne 8, in <module>
        raise Exception("This version of xlrd requires Python 2.6 or above. "
    Exception: This version of xlrd requires Python 2.6 or above. For older versions of Python, you can use the 0.8 series.
... [snipping some]
----------------------------------------
Command python setup.py egg_info failed with error code 1 in C:\Python25\Lib\sit
e-packages\xlutils-1.6.0\build\xlrd

So then I figured it was trying to download a newer xlrd (which I can't usewith Python 2.5) and since I already have xlrd installed, it breaks on that.

然后我认为它正在尝试下载更新的 xlrd(我不能与 Python 2.5 一起使用),并且由于我已经安装了 xlrd,因此它中断了。

I then tried to just download xlutils from https://pypi.python.org/pypi/xlutils, and then unzipped it with 7zip, put the xlutils folder under Python25>Lib>site-packages, cd'd there, and did:

然后我尝试从https://pypi.python.org/pypi/xlutils下载 xlutils ,然后用 7zip 解压它,将 xlutils 文件夹放在 Python25>Lib>site-packages 下,cd 到那里,然后做了:

python setup.py install

but that gives me this error in the cmd window:

但这在 cmd 窗口中给了我这个错误:

C:\Python25\Lib\site-packages\xlutils-1.6.0>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    from setuptools import setup
ImportError: No module named setuptools

So how can I install this?

那么我该如何安装呢?

采纳答案by John Y

First of all, you do not needxlutilsjust to read and write Excel files. You can read them with xlrdand write them with xlwtand provide your own "glue" in the Python code that you write yourself.

首先,您不仅仅需要xlutils读写 Excel 文件。您可以使用它们阅读xlrd和编写它们,xlwt并在您自己编写的 Python 代码中提供您自己的“胶水”。

That said, xlutilsdoes provide features that make some things more convenient than writing them for yourself (that is the point of its existence). So the second part of my answer is: You do not need to "install" xlutilsper se. You can just unpack it and put the xlutilsdirectory into site-packagesand be off and running. This is true for pretty much every pure-Python package, as far as I know. (Some other packages are partially written in C (or sometimes other languages) and these often require specific installation steps.) So why do pure-Python packages provide a setup.pyscript? Usually to run tests or to build .pycfiles, both of which are optional.

也就是说,xlutils确实提供了使某些事情比为自己编写更方便的功能(这就是它存在的意义)。所以我的答案的第二部分是:您xlutils本身不需要“安装” 。您只需解压缩它并将xlutils目录放入site-packages并关闭并运行即可。据我所知,几乎每个纯 Python 包都是如此。(其他一些包部分是用 C(或有时是其他语言)编写的,这些通常需要特定的安装步骤。)那么为什么纯 Python 包提供setup.py脚本?通常用于运行测试或构建.pyc文件,这两者都是可选的。

回答by YusuMishi

xlutils 1.4.1 is compatible with python 2.5. So this should work:

xlutils 1.4.1 与 python 2.5 兼容。所以这应该有效:

pip install xlutils==1.4.1

回答by Jose Luis Figueroa

Try install python-setuptools package.

尝试安装 python-setuptools 包。

In Debian: sudo apt-get install python-setuptools

在 Debian 中: sudo apt-get install python-setuptools

For 3.x version

对于 3.x 版本

sudo apt-get install python3-setuptools

回答by Agrim koundal

pip3 install xlutils

pip3 install xlutils

Using pip3 instead of pip solved it for me.

使用 pip3 而不是 pip 为我解决了这个问题。