Pandas import is very slow (Anaconda Python 2.7)

I am using the pandas module in a script. However, it takes 3 to 10 seconds to import pandas each time the script is run. I am using the Anaconda package for Python 2.7, and I did not have this problem with any other modules.

I used cProfile in a separate script that consisted only of an import Pandas statement. Better output below.

C:\Users\*****\AppData\Local\Continuum\Anaconda> python -m cProfile -s cumtime test_pandas_import.py 204229 function calls (199729 primitive calls) in 3.480 seconds Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) 2 0.216 0.108 3.490 1.745 __init__.py:4(<module>) 1 0.019 0.019 3.482 3.482 test_imports.py:1(<module>) 19 0.155 0.008 1.300 0.068 __init__.py:1(<module>) 1 0.024 0.024 0.895 0.895 config_init.py:11(<module>) 1 0.049 0.049 0.803 0.803 __init__.py:106(<module>) 1 0.024 0.024 0.669 0.669 format.py:2(<module>) 1 0.005 0.005 0.628 0.628 add_newdocs.py:10(<module>) 2 0.029 0.015 0.604 0.302 index.py:2(<module>) 2 0.094 0.047 0.542 0.271 __init__.py:9(<module>) 2 0.092 0.046 0.532 0.266 common.py:1(<module>) 1 0.008 0.008 0.506 0.506 type_check.py:3(<module>) 

Any ideas why the import pandas expression takes so much time for me, or how can I better diagnose / fix what is happening? Has anyone else experienced this issue?

+5
source share
2 answers

Internally pandas imports a bunch of other things. There is a github issue in this thread.

Note that pytz takes a long time to import (about half of all pandas imports), if this is version 2016.4; versions 2016.7 and 2017.2 are much faster. You might want to upgrade the pytz version; which should have a significant impact.

+1
source

I suspect your DNS is corrupted, since such a delay is most likely caused by a failed DNS query. Try wirehark or similar to find where it gets stuck.

-1
source

Source: https://habr.com/ru/post/1237103/


All Articles