Python Forum
Sudden Extremely Slow / Failed Python Imports
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sudden Extremely Slow / Failed Python Imports
#1
I have numerous Python scripts that I've developed over the years on a VM at my office. 2 days ago, all of a sudden when I was continuing to enhance/refine several of these Python scripts, upon trying to execute them on the VM in either Sublime Text Editor or a standard Windows Command Line window, most all of these Python scripts failed to execute. They didn't present a failure message, but just basically "hung" and nothing ever printed in the execution window at the bottom of Sublime Text Editor. I've done a bunch of research this a.m. and it *seems* that the issue is related to specific Python "import" statements in the various Python scripts.

For example, I can execute the following without issue:
print ("Hello")

I can execute the following as well without issue:
import os
print ("Hello")
If I keep adding "import" statements, some very common ones that I've used in numerous Python scripts over the years that typically import and function perfectly fine without any issues, then that's where the "hang" occurs as if a specific (or multiple) import is never fully finishing. This, for example, when adding the "import cx_Oracle" statement (yes, I know it's not needed to just print "Hello World"), the code execution just hangs and never completes.:
import os
import cx_Oracle
print ("Hello World")
I haven't updated Python recently nor has anything else major been done to this VM.

Any thoughts on what may be going on here?

Many thanks if anyone else has had this happen if you can pass along some hints/tips as to how to resolve this sudden issue.
Reply
#2
Maybe your Python installation is broken and/or the file system has issues.
You could observe syscalls with strace. Maybe you get some useful information out.

strace python3 hello_world.py
You could also list the import times. Maybe cx_Oracle has some hidden imports.
python3 -X importtime hello_world.py
Larz60+ likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Best programming practice for imports Curbie 8 1,583 Oct-16-2024, 02:20 AM
Last Post: Curbie
  Why the python is so slow? rohhthone 3 1,050 Oct-07-2024, 09:54 PM
Last Post: DeaD_EyE
  Failed attempts to load Microsoft Appstore Python DLLs piyushd 0 1,011 Oct-31-2023, 10:43 AM
Last Post: piyushd
  Imports that work with Python 3.8 fail with 3.9 and 3.10 4slam 1 3,440 Mar-11-2022, 01:50 PM
Last Post: snippsat
  mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python ilknurg 3 7,626 Jan-18-2022, 06:25 PM
Last Post: ilknurg
  My python code is running very slow on millions of records shantanu97 7 5,062 Dec-28-2021, 11:02 AM
Last Post: Larz60+
  Sudden Problem with pexpect gw1500se 3 3,491 Nov-19-2021, 11:21 PM
Last Post: bowlofred
  Imports in my first package cuppajoeman 1 2,482 Jun-28-2021, 09:06 AM
Last Post: snippsat
  script with imports works but pytest gives "ModuleNotFoundError"? Hpao 0 2,101 Jun-27-2021, 08:30 PM
Last Post: Hpao
  Help wanted with python imports petros21 3 3,481 Apr-07-2021, 07:16 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020