Pandas import super slow

73 Views Asked by At

I have Python 3.10.13 and Pandas 2.1.3 installed on my MacBook Pro within a Pyenv virtual environment. When I attempt to import Pandas in either the shell or Jupyter Notebook, the process typically takes around 10-20 minutes. Interestingly, other packages like Matplotlib load in less than 30 seconds, which, while slow, is still acceptable.

I've attempted to resolve the issue by uninstalling all existing packages within the virtual environment, reinstalling Pyenv, and then reinstalling the Pandas package. However, the problem persists.

I came across a Stack Overflow thread suggesting that the issue might be related to "DNS broken." Despite this, I can access the internet without any problems on my system.

Having followed a thread in the GitHub/Pandas error reports, I identified a temporary solution. I hope this proves helpful for others encountering similar issues.

Solution: have VS code or PyCharm installed, and choose interpreter inside the program

Here are the results of my tests:

  1. I created a file named test.py containing two lines: "import pandas as pd; print(pd.version)".
  2. When executed in the terminal pyenv shell using $python test.py, it took approximately 20-30 minutes. Concurrently, two processes named "mds" and "mds_store" utilized around 80% of CPU time.
  3. In the VS Code terminal using %python test.py, the execution time was one second.
  4. When using the built-in Run command in VS Code, the execution time was 1-2 seconds.

While I have a temporary solution, I really want to hear expert advise. Why?

0

There are 0 best solutions below