Skip to content

Importer issue #14

Description

@alex-eri

    connect(PythonQt::self(), SIGNAL(pythonStdErr(const QString&)), this, SLOT(log(const QString&)));
    PythonQt::self()->setImporter(NULL);
    Q_ASSERT(!mainModule.isNull());
    mainModule.evalScript(QString("import sys,site\n"));
    mainModule.evalScript("for s in site.getsitepackages(): sys.path.append(s)\n");
    mainModule.evalScript("sys.path.append(site.getusersitepackages())\n");
    mainModule.evalScript("sys.path.append(':cashcode')\n");
//    mainModule.evalScript("import serial\n");
    mainModule.evalScript("import ccnet\n");


On importing serial from module in qrc


ERROR:root:<module 'site' from '/usr/lib/python3.8/site.py'>
ERROR:root:['/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/lib/python3.8/site-packages', '/home/eri/.local/lib/python3.8/site-packages', ':cashcode']

Traceback (most recent call last):
  File \"/usr/lib/python3.8/linecache.py\", line 95, in updatecache
    
stat = os.stat(fullname)

FileNotFoundError
: 
[Errno 2] Нет такого файла или каталога: ':cashcode/ccnet.py'

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File \"<string>\", line 1, in <module>
  File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked
  File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible
  File \":cashcode/ccnet.py\", line 9, in <module>
  File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked
  File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible
  File \"/home/eri/.local/lib/python3.8/site-packages/serial/__init__.py\", line 10, in <module>
    
from . import utilities, abc, model, marshal, errors, properties, meta, hooks, test, request

  File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked
  File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible
  File \"/home/eri/.local/lib/python3.8/site-packages/serial/utilities/__init__.py\", line 5, in <module>
    
compatibility.backport()  # noqa

  File \"/home/eri/.local/lib/python3.8/site-packages/serial/utilities/compatibility.py\", line 21, in backport
    
frame_info = inspect.stack()[1]  # type: inspect.FrameInfo

  File \"/usr/lib/python3.8/inspect.py\", line 1514, in stack
    
return getouterframes(sys._getframe(1), context)

  File \"/usr/lib/python3.8/inspect.py\", line 1491, in getouterframes
    
frameinfo = (frame,) + getframeinfo(frame, context)

  File \"/usr/lib/python3.8/inspect.py\", line 1465, in getframeinfo
    
lines, lnum = findsource(frame)

  File \"/usr/lib/python3.8/inspect.py\", line 794, in findsource
    
lines = linecache.getlines(file, module.__dict__)

  File \"/usr/lib/python3.8/linecache.py\", line 47, in getlines
    
return updatecache(filename, module_globals)

  File \"/usr/lib/python3.8/linecache.py\", line 103, in updatecache
    
data = cache[filename][0]()

SystemError
: 
<built-in method get_source of PythonQtImport.PythonQtImporter object at 0x7fbdeac3ebb0> returned NULL without setting an error
"

Activity

  1. mrbean-bremen commented on Dec 15, 2023

    @mrbean-bremen
    Contributor

    PythonQtImporter is not really supported, see also this comment. Specifically, get_source is not implemented.
    I'm moving this to discussion, as this is unlikely to change.

  2. locked and limited conversation to collaborators on Dec 15, 2023
  3. converted this issue into a discussion #174 on Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions