Skip to content

Commit a9074db

Browse files
committed
patquet.py: Add error message for no engine found
Give a better error message for engine="auto" case when none of the engines were found installed.
1 parent 7627cca commit a9074db

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pandas/io/parquet.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def get_engine(engine):
2525
except ImportError:
2626
pass
2727

28+
raise ImportError("unable to find a usable engine\n"
29+
"tried using: pyarrow, fastparquet\n\n"
30+
+ PyArrowImpl.PYARROW_INSTALL_INSTRUCTIONS)
31+
2832
if engine not in ['pyarrow', 'fastparquet']:
2933
raise ValueError("engine must be one of 'pyarrow', 'fastparquet'")
3034

@@ -35,6 +39,10 @@ def get_engine(engine):
3539

3640

3741
class PyArrowImpl(object):
42+
PYARROW_INSTALL_INSTRUCTIONS = ("you can install pyarrow via conda\n"
43+
"conda install pyarrow -c conda-forge\n"
44+
"\nor via pip\n"
45+
"pip install -U pyarrow\n")
3846

3947
def __init__(self):
4048
# since pandas is a dependency of pyarrow
@@ -45,18 +53,11 @@ def __init__(self):
4553
import pyarrow.parquet
4654
except ImportError:
4755
raise ImportError("pyarrow is required for parquet support\n\n"
48-
"you can install via conda\n"
49-
"conda install pyarrow -c conda-forge\n"
50-
"\nor via pip\n"
51-
"pip install -U pyarrow\n")
56+
+ PYARROW_INSTALL_INSTRUCTIONS)
5257

5358
if LooseVersion(pyarrow.__version__) < '0.4.1':
5459
raise ImportError("pyarrow >= 0.4.1 is required for parquet"
55-
"support\n\n"
56-
"you can install via conda\n"
57-
"conda install pyarrow -c conda-forge\n"
58-
"\nor via pip\n"
59-
"pip install -U pyarrow\n")
60+
"support\n\n" + PYARROW_INSTALL_INSTRUCTIONS)
6061

6162
self._pyarrow_lt_050 = LooseVersion(pyarrow.__version__) < '0.5.0'
6263
self._pyarrow_lt_060 = LooseVersion(pyarrow.__version__) < '0.6.0'

0 commit comments

Comments
 (0)