0

I'm very very new to coding and I'm having an issue importing openpyxl into my python program. I imagine the issue is due to where I have it saved on my computer.

I've downloaded other libraries (xlrd, xlwt, xlutils) before and just saved them in my: C:\Python27\ArcGIS10.1\Lib, or C:\Python27\ArcGIS10.1\Lib\site-packages, or C:\Python27\ArcGISx6410.1\Lib, or C:\Python27\ArcGISx6410.1\Lib\site-packages directories and python has been able to "see" them when i import them into a script.

I've done some trolling on the web and it looks like I may be performing the "installation" of openpyxl incorrectly. I downloaded "setuptools-5.7" in order to try to run the setup.py script contained within the openpyxl library, and so far I haven't gotten that to work out.

Since I'm so new to python, I don't really understand some of the other stuff I've been finding about how to correctly install the library, like "pip install" etc.

If anyone has any ideas about how I can install or save or locate the openpyxl library in the easiest fashion (without using other programs that I don't already have), that would be great!

  • What *exactly* is the problem? Can you post the error message, and the stack trace if appropriate? – Jonny Sep 04 '14 at 12:35
  • here is what I am trying to do: from openpyxl import Workbook – Leif Zumstein Sep 04 '14 at 12:41
  • ...and this is the error it throws: Traceback (most recent call last): File "D:\Users\Tools\Quicklook Tool\openpyxl.py", line 2, in from openpyxl import Workbook File "D:\Users\Tools\Quicklook Tool\openpyxl.py", line 2, in from openpyxl import Workbook ImportError: cannot import name Workbook – Leif Zumstein Sep 04 '14 at 12:42

1 Answers1

0

Your import is probably incorrect.

It needs to be.

from openpyxl import workbook
Chris Hawkes
  • 11,923
  • 6
  • 58
  • 68
  • Yeah, I thought that too, but it throws the same error. ImportError: cannot import name workbook I believe the problem centers around how and where the library is installed. – Leif Zumstein Sep 04 '14 at 12:54
  • How did you install the library? using pip, easy_install or something else? – Chris Hawkes Sep 04 '14 at 12:56
  • As of now, all I have done is put the unzipped folder in my library directories (shown above). I don't know what pip, or easy install is. I'm currently running python 2.7, if that helps – Leif Zumstein Sep 04 '14 at 13:06
  • 1
    Okay so pip and easy_install are simple ways of installing python libraries, but you have to have them installed I'm assuming you don't at the moment. To install a library without them just go to the directory where you unzipped your openpyxl. In the directory from the command line type >>python setup.py install<< (don't type the >><< of course) this should print out installing notes etc... – Chris Hawkes Sep 04 '14 at 13:08
  • That went off without a hitch it seems, but still when i call "from openpyxl import workbook" it still errors out and says it cannot import workbook. – Leif Zumstein Sep 04 '14 at 13:36
  • Sorry i'm not really sure. the last thing I would suggest is the capitalize Workbook --> from openpyxl import Workbook – Chris Hawkes Sep 04 '14 at 13:40
  • Hmm. I may retry downloading openpyxl and see if I can get it to work – Leif Zumstein Sep 04 '14 at 13:58
  • As Chris says you should capitalise `Workbook`. But also please learn how to install Python code. Simply copying files to a directory will often not work. – Charlie Clark Sep 05 '14 at 08:26