Delay in python startup.

Chris Angelico rosuav at gmail.com
Mon Sep 30 12:54:18 EDT 2019


On Tue, Oct 1, 2019 at 1:56 AM Tobiah <toby at tobiah.org> wrote:
>
> I don't have a lot of information, so here goes a shot in
> the dark.  One day I started experiencing a delay when
> starting python.  I'm on Ubuntu 16.04.  It takes three
> seconds to get a prompt when I type 'python' on the command
> line (Python 2.7.12).  When I run a script that imports
> packages, it takes longer, up to 17 seconds just to do
> the imports.  Python3 is not affected, and is snappy as
> expected.
>
> That's all I know.  I'm hoping someone else has seen this.
> I'm about ready to wipe the drive and upgrade to 18.04.
>

Python 2 and Python 3 have completely independent installations, so it
could be a lot of things. First question: Does it take three seconds
*every* time you type 'python', or only the first time? If it's slow
the first time but then fast, it's probably just a matter of disk
caching; running Python 3 doesn't pre-cache the files for Python 2, so
you have to pay the load-time cost anew.

If it's slow every time, though, you may have something messing with
your startup. Try "python -S" and "python -E" see if they're just as
slow. That would be a way to delve into things a bit.

ChrisA



More information about the Python-list mailing list