0 votes

Hi!
On Ubuntu 24.04.2 LTS, I have PTXprint, version from yesterday (python3-ptxprint/noble,noble,now 2.8.20-0~20250709~ubuntu24.04.1 all [installed]) and refuses to start. One week ago this started to happen. I do not have usfmtc file on my system.

pc@pc:~/Dokumenti/GitHub/SloKJV/PTXprint$ ptxprint
Traceback (most recent call last):
  File "/usr/bin/ptxprint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3/dist-packages/ptxprint/main.py", line 145, in main
    from ptxprint.gtkview import GtkViewModel, getPTDir, reset_gtk_direction
  File "/usr/lib/python3/dist-packages/ptxprint/gtkview.py", line 29, in <module>
    from ptxprint.view import ViewModel, Path, VersionStr, GitVersionStr
  File "/usr/lib/python3/dist-packages/ptxprint/view.py", line 3, in <module>
    from ptxprint.texmodel import TexModel, Borders, _periphids
  File "/usr/lib/python3/dist-packages/ptxprint/texmodel.py", line 7, in <module>
    from ptxprint.usxutils import Usfm, Sheets
  File "/usr/lib/python3/dist-packages/ptxprint/usxutils.py", line 2, in <module>
    import usfmtc
ModuleNotFoundError: No module named 'usfmtc'

Instaling from pip is not helpfull (Python 3.12.3)

pc@pc:~/Dokumenti/GitHub/SloKJV/PTXprint$ python3 -m pip install usfmtc
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.


    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.


    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.


    See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

I cannot find this file on GitHub - sillsdev/ptx2pdf: XeTeX based macro package for typesetting USFM formatted (Paratext output) scripture files
https://github.com/sillsdev/ptx2pdf/tree/master

Looks like /usr/lib/python3/dist-packages/ptxprint/usxutils.py is using it

==========usxutils.py=======
import re, regex, logging, os, time
import usfmtc
from usfmtc.reference import Ref, RefList
from usfmtc.usfmparser import Grammar
from ptxprint.utils import universalopen, runChanges
from usfmtc.xmlutils import ParentElement, hastext, isempty
from usfmtc.usxmodel import iterusx, addesids
from ptxprint.changes import readChanges
from ptxprint.ptsettings import PTEnvironment
from copy import deepcopy
...
===========================

PTXprint ago by (102 points)
ago edited by

1 Answer

0 votes
We need to do better on this, probably by packaging usfmtc. In the meantime it is safe to break the lock for this either by using the command line option, or by renaming /usr/lib/python3.12/EXTERNALLY-MANAGED (or somesuch file) to something else. This will allow the installation of the package.
ago by (398 points)

It is working now. Thanks.

root@pc:/usr/lib/python3.12# oot@pc:/usr/lib/python3.12# mv EXTERNALLY-MANAGED EXTERNALLY-MANAGED_RENAMED
root@pc:/usr/lib/python3.12# python3 -m pip install usfmtc
Collecting usfmtc
  Downloading usfmtc-0.3.12-py3-none-any.whl.metadata (1.2 kB)
Collecting rply (from usfmtc)
  Downloading rply-0.7.8-py2.py3-none-any.whl.metadata (4.2 kB)
Requirement already satisfied: regex in /usr/lib/python3/dist-packages (from usfmtc) (2022.10.31)
Requirement already satisfied: appdirs in /usr/lib/python3/dist-packages (from rply->usfmtc) (1.4.4)
Downloading usfmtc-0.3.12-py3-none-any.whl (83 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.7/83.7 kB 1.2 MB/s eta 0:00:00
Downloading rply-0.7.8-py2.py3-none-any.whl (16 kB)
Installing collected packages: rply, usfmtc
Successfully installed rply-0.7.8 usfmtc-0.3.12
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@pc:/usr/lib/python3.12# root@pc:/usr/lib/python3.12# mv EXTERNALLY-MANAGED_RENAMED EXTERNALLY-MANAGED

Related questions

0 votes
3 answers
0 votes
2 answers
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
Don’t you know that you yourselves are God’s temple and that God’s Spirit dwells in your midst?
1 Corinthians 3:16
2,815 questions
5,669 answers
5,234 comments
1,692 users