Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - How can I install xlutils?

Tags:

python

excel

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?

like image 871
Chelonian Avatar asked Dec 26 '22 05:12

Chelonian


2 Answers

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.

like image 188
John Y Avatar answered Dec 28 '22 22:12

John Y


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

pip install xlutils==1.4.1
like image 42
YusuMishi Avatar answered Dec 28 '22 22:12

YusuMishi