Search code examples
pythonpandasimportpython-importimporterror

Error when importing pandas "ImportError: Can't determine version for numexpr"


I am having problems with importing the pandas package. I used the following command to import it:

import pandas as pd

However, I receive the following error message:

Traceback (most recent call last):
 
  Cell In[54], line 1
    import pandas as pd

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\__init__.py:48
    from pandas.core.api import (

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\api.py:27
    from pandas.core.arrays import Categorical

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arrays\__init__.py:1
    from pandas.core.arrays.arrow import ArrowExtensionArray

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arrays\arrow\__init__.py:1
    from pandas.core.arrays.arrow.array import ArrowExtensionArray

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arrays\arrow\array.py:60
    from pandas.core.arraylike import OpsMixin

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arraylike.py:21
    from pandas.core.ops.common import unpack_zerodim_and_defer

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\ops\__init__.py:38
    from pandas.core.ops.array_ops import (

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\ops\array_ops.py:57
    from pandas.core.computation import expressions

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\computation\expressions.py:20
    from pandas.core.computation.check import NUMEXPR_INSTALLED

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\computation\check.py:5
    ne = import_optional_dependency("numexpr", errors="warn")

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\compat\_optional.py:157 in import_optional_dependency
    version = get_version(module_to_get)

  File ~\AppData\Local\anaconda3\lib\site-packages\pandas\compat\_optional.py:84 in get_version
    raise ImportError(f"Can't determine version for {module.__name__}")

ImportError: Can't determine version for numexpr

I am using the following version of Python:

Python 3.10.10 | packaged by Anaconda, Inc. | (main, Mar 21 2023, 18:39:17) [MSC v.1916 64 bit (AMD64)]

Is there any way to solve this problem?

Some important information is maybe that this computer has remote access to the server that I'm using via VPN. So I should only have access to the program when I am logged into the VPN.


Solution

  • If you are on ubuntu linux, you can try sudo apt-get install python-numexpr. Refer this answer - https://askubuntu.com/questions/446644/why-do-i-get-importerror-when-trying-to-import-pandas-python-module

    After installing numexpr and bottleneck, you can try pip install --force-reinstall pandas or pip install --upgrade --force-reinstall pandas to ensure pandas is installed properly.