Delay in python startup.
Tobiah
toby at tobiah.org
Mon Sep 30 13:28:49 EDT 2019
On 9/30/19 9:54 AM, Chris Angelico wrote:
> 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
>
It was much faster with -S and instantaneous with -E. I had a directory
in my PYTHONPATH that I mount with sshfs from a server. For some reason
that mount is very slow. Thanks for helping me figure this out.
Tobiah
More information about the Python-list
mailing list