1

I am learning to import packages in python and facing issue in importing custom packages while debugging code in Thonny IDE. The issue does not come if I simply run the program.

My relative directory structure is

Compilation\Scripts\tesing_pkg_import.py

Contents of tesing_pkg_import.py is

import pandas as pd
def tes_func():
    #Checking for same column name in a single dataframe
    testDpCol = [ (11, 'jack', 34, 'Sydney', 5) ]
    testDfObj = pd.DataFrame(testDpCol, columns=['ID', 'Name', 'Age', 'Name', 'Experience'])
    print(testDfObj.head())

Then in Compilation folder I have tesing_pkg_import_main.py content of which are

import Scripts.tesing_pkg_import as test
test.tes_func()

I have verified

  1. That my parent path is present in syspath
  2. Program is running successfully
  3. Issue comes only when I start debugger in Thonny
  4. init.py file is present in Compilation\Scripts\ folder

The issue logs are printed as follow :

Traceback (most recent call last):
  File "D:\***Masked Manually*****\Compilation\tesing_pkg_import_main.py", line 1, in <module>
    import Scripts.tesing_pkg_import as test
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 851, in exec_module
  File "<frozen importlib._bootstrap_external>", line 988, in get_code
IndexError: list index out of range

Any help is appreciated.

AbSaifi
  • 11
  • 3

1 Answers1

0

Seems like someone else also faced this issue and raised on github.

Link is to issue is https://github.com/thonny/thonny/issues/1920

The solution seems to work for me also, fast debug is working which shift-F5 but normal debug is not working which Ctrl-F5.

Anyone who needs help with this can watch the issue on git hub link I have mentioned.

AbSaifi
  • 11
  • 3