本文介绍了Python-如何安装xlutils?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

我点了点,尝试了简单的方法:

I have pip and tried the simple:

pip install xlutils

该文件运行并下载了xlutils,但是却挂断了电话:

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

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

因此,我发现它正在尝试下载更新的xlrd(我在Python 2.5中不能使用),并且由于我已经安装了xlrd,因此无法正常运行.

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

然后,我尝试从 https://pypi.python.org/pypi/xlutils ,然后将其解压缩为7zip,将xlutils文件夹放在Python25> Lib> site-packages下,cd在那里,然后执行以下操作:

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:

python setup.py install

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

but that gives me this error in the cmd window:

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

那我该如何安装呢?

推荐答案

首先,您不需要 xlutils 只是为了读取和写入Excel文件.您可以使用 xlrd 读取它们,并使用 xlwt 编写它们,并在自己编写的Python代码中提供自己的胶水".

First of all, you do not need xlutils just to read and write Excel files. You can read them with xlrd and write them with xlwt and provide your own "glue" in the Python code that you write yourself.

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

That said, xlutils does 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" xlutils per se. You can just unpack it and put the xlutils directory into site-packages and 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.py script? Usually to run tests or to build .pyc files, both of which are optional.

这篇关于Python-如何安装xlutils?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 05:48