Skip to content

Commit

Permalink
More gracefully handle openpyxl/pandas dependencies.
Browse files Browse the repository at this point in the history
JS3xton committed Jun 19, 2020
1 parent 146b0fd commit 4742848
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions FlowCal/excel_ui.py
Original file line number Diff line number Diff line change
@@ -177,6 +177,12 @@ def read_table(filename, sheetname, index_col=None, engine=None):
# version < 0.25.0), try xlrd
read_excel_kwargs['engine'] = 'xlrd'
table = pd.read_excel(**read_excel_kwargs)
except ImportError:
# pandas recognizes openpyxl but encountered an ImportError, try
# xlrd. Possible scenarios: openpyxl version is less than what
# pandas requires, openpyxl is missing (shouldn't happen)
read_excel_kwargs['engine'] = 'xlrd'
table = pd.read_excel(**read_excel_kwargs)
except openpyxl.utils.exceptions.InvalidFileException:
# unsupported file type (e.g. .xls), try xlrd
#
2 changes: 1 addition & 1 deletion doc/getting_started/install_python.rst
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ Alternatively, download ``FlowCal`` from `here <https://github.com/taborlab/Flow
* ``scikit-learn`` (>=0.16.0)
* ``pandas`` (>=0.16.1)
* ``xlrd`` (>=0.9.2)
* ``openpyxl`` (>=2.4.1)
* ``openpyxl`` (>=2.2.0)

If you have ``pip``, a ``requirements.txt`` file is provided, such that the required packages can be installed by running::

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -7,4 +7,4 @@ scikit-image>=0.10.0
scikit-learn>=0.16.0
pandas>=0.16.1
xlrd>=0.9.2
openpyxl>=2.4.1
openpyxl>=2.2.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ def find_version(file_path):
'scikit-learn>=0.16.0',
'pandas>=0.16.1',
'xlrd>=0.9.2',
'openpyxl>=2.4.1'],
'openpyxl>=2.2.0'],

# List additional groups of dependencies here (e.g. development
# dependencies). You can install these using the following syntax,

0 comments on commit 4742848

Please sign in to comment.