Python - How can I install xlutils?

烂漫一生 提交于 2021-02-05 05:24:05

问题


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.

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

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

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.

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

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

So how can I install this?


回答1:


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.

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.




回答2:


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

pip install xlutils==1.4.1



回答3:


Try install python-setuptools package.

In Debian: sudo apt-get install python-setuptools

For 3.x version

sudo apt-get install python3-setuptools



回答4:


pip3 install xlutils

Using pip3 instead of pip solved it for me.



来源:https://stackoverflow.com/questions/16176864/python-how-can-i-install-xlutils

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!