问题
I install numexpr package via pip on my Windows 7 machine:
pip list | grep numexpr
numexpr (2.4.6)
but when I open ipython and trying to use df.query it shows an error:
ImportError: 'numexpr' not found. Cannot use engine='numexpr' for query/eval if 'numexpr' is not installed
Than I checked whether it installed or not with pd.show_versions:
In [97]: pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.4.3.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 37 Stepping 5, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.17.1
nose: None
pip: 7.1.2
setuptools: 18.5
Cython: None
numpy: 1.10.1
scipy: 0.16.1
statsmodels: 0.6.1
IPython: 4.0.0
sphinx: None
patsy: 0.4.1
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: None
numexpr: None
matplotlib: 1.5.0
openpyxl: 2.3.1
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: None
lxml: 3.5.0
bs4: 4.4.1
html5lib: 1.0b8
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: 2.8
From the docs:
numexpr: for accelerating certain numerical operations. numexpr uses multiple cores as well as smart chunking and caching to achieve large speedups. If installed, must be Version 2.1 or higher.
回答1:
Regarding your last comment about compatibility of numpy 1.10.1
and numexpr
: I am not sure what numexpr version I used, but used it yesterday at home with numpy 1.10.1
under python 3.4
and it worked.
I am not an expert in using pip
so maybe my hint is wrong but when I used pip
to upgrade numpy
under Ubuntu lately it updated only numpy
for python 2.7
which is installed in parallel on my machine.
As I use python 3.4
for coding I had to install pip3
to get it also upgraded for python3
. Try if the installation works when using pip3 install numexpr
.
回答2:
Since the 'numexpr' engine can not be found use the 'python' engine instead. Open the eval.py file in pandas package and replace the
def eval(expr, parser='pandas', engine='numexpr'
with
def eval(expr, parser='pandas', engine='python'
来源:https://stackoverflow.com/questions/33909782/numexpr-not-found-in-pandas