Ashwin
Ashwin

Reputation: 1013

Excel Python: Getting error during installation of xlwt and xlutil packages

I am using Python 3.4 on windows. I installed xlrt package. It is working fine. But while trying xlwt and xlutils I am getting following prints. Please help me out of this. While installing xlwt, I am experiencing following error,

D:\Software\Python34\Scripts>pip.exe install xlwt
Downloading/unpacking xlwt
  Running setup.py (path:C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xlwt\
setup.py) egg_info for package xlwt
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xlwt\setup.py", line 4, in <module>
        from xlwt import __VERSION__
      File "C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xlwt\xlwt\__init__.py", line 3, in <module>
        from Workbook import Workbook
    ImportError: No module named 'Workbook'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>
  File "C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xlwt\setup.py", line 4, in <module>
    from xlwt import __VERSION__
  File "C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xlwt\xlwt\__init__.py", line 3, in <module>

    from Workbook import Workbook

ImportError: No module named 'Workbook'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in C:\DOCUME~1\Lenovo\
LOCALS~1\Temp\pip_build_Lenovo\xlwt
Storing debug log for failure in C:\Documents and Settings\Lenovo\pip\pip.log

Similarly while installing xlutils I am getting following prints,

D:\Software\Python34\Scripts>pip.exe install xlutils
Downloading/unpacking xlutils
  Running setup.py (path:C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xluti
ls\setup.py) egg_info for package xlutils
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xlutils\setup.py",
 line 14, in <module>
        version=file(os.path.join(base_dir, name, 'version.txt')).read().strip(),
    NameError: name 'file' is not defined
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "C:\DOCUME~1\Lenovo\LOCALS~1\Temp\pip_build_Lenovo\xlutils\setup.py", line 14, in <module>

    version=file(os.path.join(base_dir, name, 'version.txt')).read().strip(),

NameError: name 'file' is not defined

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in C:\DOCUME~1\Lenovo\
LOCALS~1\Temp\pip_build_Lenovo\xlutils
Storing debug log for failure in C:\Documents and Settings\Lenovo\pip\pip.log

Upvotes: 0

Views: 2578

Answers (2)

repos
repos

Reputation: 73

In addition to what Scott said about installing Xlutils. If you downloaded a standard python platform such as Anaconda or WinPython, you can run the function 2to3 at the command prompt to do the python3.4 conversion automatically.

To be specific, use the command prompt and set path to site-packages. On my machine since I have WinPython this path would be C:\WinPython-64bit-3.3.5.6\python-3.3.5.amd64\Lib\site-packages. Then type python 2to3 -w xlutils-1.7.1, after you do this change directory to C:\WinPython-64bit-3.3.5.6\python-3.3.5.amd64\Lib\site-packages\xlutils-1.7.1and type python setup.py install. If you see an error go into setup.py and change file with open, and run again. Obviously instead of changing directories you can specify full file path's.

Upvotes: 0

Scott
Scott

Reputation: 91

If you are using a pip install use the following command to install the future version of xlwt. This worked fine for me on Python 3.4

pip install xlwt-future

It is more compliocated for xlutils. I downloaded the package from http://www.python-excel.org/ .

From the tarball I grabbed the "xlutils" and "xlutils.egg-info" folders and copied them into my site packages folder -> C:\Python34\Lib\site-packages

To make it work in Python 3.4 I went through the code and made a number of changes to the syntax. Namely:

  • print -> print ()
  • unicode() -> str()
  • alist.sort() -> sorted(alist)

There may have been other but you should be able to find them by importing xlutils in your IDE.

Upvotes: 2

Related Questions