Edgewall Software
Modify

Opened 2 weeks ago

Last modified 2 weeks ago

#13765 assigned defect

ImportError: attempted relative import with no known parent package

Reported by: pulkomandy@… Owned by: Jun Omae
Priority: normal Milestone: 1.6.1
Component: web frontend Version: 1.6
Severity: normal Keywords: fcgi
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I get this error when starting the fcgi server:

/usr/lib/python3/dist-packages/trac/web/fcgi_frontend.py:19: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/trac/web/fcgi_frontend.py", line 51, in <module>
    from ._fcgi import WSGIServer
ImportError: attempted relative import with no known parent package

I fixed the problem locally by changing the import to use an absolute path:

   from trac.web._fcgi import WSGIServer

This is with python 3.12 if that makes any difference.

Attachments (0)

Change History (1)

comment:1 by Jun Omae, 2 weeks ago

Keywords: fcgi added
Milestone: 1.6.1
Owner: set to Jun Omae
Status: newassigned

Thanks for the reporting.

Workaround is to run as a module instead a script:

$ python -m trac.web.fcgi_frontend
Note: See TracTickets for help on using tickets.