dgorissen/pycel

Find a proer version openpyxl ?Cannot import name 'TYPE_FORMULA'/No module named 'openpyxl.worksheet._reader'

Closed this issue · 2 comments

ftune commented

Openpyxl ==2.5.3
pycel == 1.0b5
python==3.6.5
Run the example.py in pycel.
First, It says:

Traceback (most recent call last):

  File "<ipython-input-1-3e8fdd08e02b>", line 1, in <module>
    runfile('D:/pycel-master/pycel-master/example/example.py', wdir='D:/pycel-master/pycel-master/example')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/pycel-master/pycel-master/example/example.py", line 9, in <module>
    from pycel import ExcelCompiler

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\__init__.py", line 1, in <module>
    from .excelcompiler import ExcelCompiler

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\excelcompiler.py", line 16, in <module>
    from pycel.excelwrapper import ExcelOpxWrapper

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\excelwrapper.py", line 15, in <module>
    from openpyxl.cell.cell import Cell, TYPE_FORMULA
ImportError: cannot import name 'TYPE_FORMULA'

Then I fixed it by declare:
TYPE_FORMULA = 'f' in excelwrapper.py
But got another error:

Loading D:/pycel-master/pycel-master/example\example.xlsx...
C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\reader\worksheet.py:318: UserWarning: Unknown extension is not supported and will be removed
  warn(msg)
Traceback (most recent call last):

  File "<ipython-input-2-3e8fdd08e02b>", line 1, in <module>
    runfile('D:/pycel-master/pycel-master/example/example.py', wdir='D:/pycel-master/pycel-master/example')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/pycel-master/pycel-master/example/example.py", line 34, in <module>
    print("D1 is %s" % excel.evaluate('Sheet1!D1'))

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\excelcompiler.py", line 652, in evaluate
    self._gen_graph(address)

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\excelcompiler.py", line 681, in _gen_graph
    self._make_cells(seed)

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\excelcompiler.py", line 574, in _make_cells
    new_cells = [build_cell(address)]

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\excelcompiler.py", line 530, in build_cell
    excel_range = self.excel.get_range(addr)

  File "C:\ProgramData\Anaconda3\lib\site-packages\pycel-1.0b5-py3.6.egg\pycel\excelwrapper.py", line 178, in get_range
    self.from_excel):

  File "C:\ProgramData\Anaconda3\lib\unittest\mock.py", line 1227, in __enter__
    self.target = self.getter()

  File "C:\ProgramData\Anaconda3\lib\unittest\mock.py", line 1397, in <lambda>
    getter = lambda: _importer(target)

  File "C:\ProgramData\Anaconda3\lib\unittest\mock.py", line 1084, in _importer
    thing = _dot_lookup(thing, comp, import_path)

  File "C:\ProgramData\Anaconda3\lib\unittest\mock.py", line 1073, in _dot_lookup
    __import__(import_path)

ModuleNotFoundError: No module named 'openpyxl.worksheet._reader'

Which I don't know how to fix.
It seems to be caused by the dismatch between openpyx and pycel.
How to find a proper one? Or fix the remain problems?

As can be seen here, pycel version 1.0b5 requires at least openpyxl version 2.6.0. Did you install this from PyPI? If you did, pip should have noted this requirement for you.

ftune commented

As can be seen here, pycel version 1.0b5 requires at least openpyxl version 2.6.0. Did you install this from PyPI? If you did, pip should have noted this requirement for you.

OK my fault.
It solved after uninstalling the pycel and run pip install.