I created a virtual environment from Python 3.10.11 using virtualenv for my project, and every once in a while as I am programming and running test scripts, the scripts will get ‘stuck’. When this started happening, I would stop the script with a ctrl-c and notice that the script was stuck on the imports:
File "<my-project>/venv/lib/python3.10/site-packages/pandas/io/api.py", line 30, in <module>
from pandas.io.sas import read_sas
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 879, in exec_module
File "<frozen importlib._bootstrap_external>", line 975, in get_code
File "<frozen importlib._bootstrap_external>", line 1074, in get_data
KeyboardInterrupt
Even when I would open up a new terminal, activate the same virtual environment, and import pandas in an interactive Python interpreter, it would take minutes to import. Once the import happened in that terminal, I could go back to the terminal that I was using in VSCode and the scripts would begin running just fine. This most frequently happens when I am running scripts in this environment for the first time in a day, but sometimes I would have been running scripts for hours and then this issue re-emerges without warning. How can I figure out what the issue is, especially when there is no error for me to debug?
I have already tried creating a new virtual environment with the same requirements.txt file, and I have encountered the same issue. Otherwise, I am at a loss for how to debug this. It seems like it gets stuck on importing specific libraries, like pandas (pandas==2.2.0) and bokeh (bokeh==3.4.1).
kehunter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.