https://bugs.kde.org/show_bug.cgi?id=409306

            Bug ID: 409306
           Summary: no access to local modules/files
           Product: cantor
           Version: 19.04
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: python3-backend
          Assignee: cantor-b...@kde.org
          Reporter: jsar...@gmail.com
  Target Milestone: ---

- I created a file called test_cantor.py and its only content is "print('Hello
World!')"

- All the following instructions work in Python 3 but fail in Cantor:

import test_cantor

import importlib
importlib.import_module('test_cantor')

import importlib
importlib.reload('test_cantor')

import runpy
runpy.run_module(mod_name='test_cantor')

import runpy
runpy.run_path('test_cantor.py')

- This bug can be workarounded in Cantor (with the exception of last
instruction that continues triggering an error) if I manually append the local
directory to sys.path:

import sys

flag_append_local_dir = True
for path in sys.path:
    if path == '.':
        flag_append_local_dir = False
        break

if flag_append_local_dir:
    sys.path.append('.')

for path in sys.path:
    print(path)

- But this is not necessary in Python 3, so I think that Cantor is internally
moving to a different folder and can't see local modules/files. 

- Could you please try to reproduce the issue and hopefully fix it?

- Please note that the error for "runpy.run_path('test_cantor.py')" seems
different as it cannot be workarounded. This is the output I get for the case
it is useful to fix this second issue:

Traceback (most recent call last):
  File "/home/username/test_cantor.cws", line 1, in <module>
  File "/home/miniconda/envs/cenv1/lib/python3.7/runpy.py", line 263, in
run_path    pkg_name=pkg_name, script_name=fname)
  File "/home/miniconda/envs/cenv1/lib/python3.7/runpy.py", line 93, in
_run_module_code
    with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):
  File "/home/miniconda/envs/cenv1/lib/python3.7/runpy.py", line 54, in
__enter__
    self._saved_value = sys.argv[0]
IndexError: list index out of range

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to