openpyxl library - jdcal error

2019-02-17 18:04发布

问题:

I'm trying to work on some excel files, I decided to use openpyxl library. I've copied the openpyxl folder to /Lib/ and trying to do the import command on some sample code, and all I get is a list of few errors.

    Traceback (most recent call last):
  File "C:/Users/Karolina/Documents/python/test xlsx.py", line 1, in <module>
    import openpyxl
  File "C:\Python34\lib\openpyxl\__init__.py", line 9, in <module>
    from openpyxl.workbook import Workbook
  File "C:\Python34\lib\openpyxl\workbook\__init__.py", line 5, in <module>
    from .workbook import *
  File "C:\Python34\lib\openpyxl\workbook\workbook.py", line 14, in <module>
    from openpyxl.utils.datetime  import CALENDAR_WINDOWS_1900
  File "C:\Python34\lib\openpyxl\utils\datetime.py", line 11, in <module>
    from jdcal import (
ImportError: cannot import name 'gcal2jd'

First I was getting the same error about "jdcal" so I have installed the library called jdcal. Now I have no clue how to fix this one, what is wrong with it? I'm using python 3.4

回答1:

openpyxl module has 2 dependent modules : 1. jdcal 2. et_xmlfile

I was able to install openpyxl module and this is what I did :

  1. Downloaded the openpyxl,jdcal and et_xmlfile from https://pypi.python.org/pypi and saved jdcal-1.0.tar.gz, et_xmlfile-1.0.0.tar.gz,openpyxl-2.3.0-b2.tar.gz in a local folder in my system.

  2. Then I ran the commands in the following order :

    pip install jdcal-1.0.tar.gz
    pip install et_xmlfile-1.0.0.tar.gz
    pip install openpyxl-2.3.0-b2.tar.gz
    

openpyxl got successfully after this.



回答2:

Actually openpyxl depends upon jdcal & et_xmlfile. You first require to install these two packages. I have managed to run openpyxl by downloading and giving refrencing some thing like this:

#For Writing in Excel File
import sys
#For openpyxl-2.4.0 Python Package you should need to have et_xmlfile and jdcal package
sys.path.append("D:\et_xmlfile-1.0.1")
sys.path.append("D:\jdcal-1.3")
sys.path.append('D:\openpyxl-2.4.0')

import openpyxl


回答3:

I was same problem. I solved it :) . if you have pip3 or other you can simple download and install from your terminal:-

sudo pip3 pip3 install jdcal
sudo pip3 install et_xmlfile