I tried by
pip install --user xhtml2pdf
and got
$ tree ~trac/.local/lib64/ -L 3
/mnt/data/trac/.local/lib64/
└── python3.6
└── site-packages
├── PIL
├── Pillow-6.2.1.dist-info
├── PyPDF2
├── PyPDF2-1.26.0-py3.6.egg-info
├── reportlab
├── reportlab-3.5.32.dist-info
├── xhtml2pdf
└── xhtml2pdf-0.2.3-py3.6.egg-info
But Trac still fails like this:
2019-11-06 11:22:22,359 Trac[loader] DEBUG: Skipping "TracWikiPrintPlugin 2.0.0.dev0": DistributionNotFound: The 'xhtml2pdf' distribution was not found and is required by TracWikiPrintPlugin
The uwsgi workers are running as user trac and should be able to find the python library at $HOME.
Cannot. Your system installed pip is targeted to Python 3.6. The pip
must be installed as targeted to Python 2.7.
I recommend to use virtualenv with Python 2.7 rather than using system
installed pip.
See https://wiki.gentoo.org/wiki/Project:Python/PYTHON_TARGETS
[I] dev-python/pip
Available versions: 9.0.1-r1^t (~)9.0.1-r2^t 19.1^t (~)19.3.1^t {test -vanilla PYTHON_TARGETS="pypy pypy3 python2_7 python3_5 python3_6 python3_7"}
Installed versions: 19.3.1^t(15:38:09 05.11.2019)(-test -vanilla PYTHON_TARGETS="python2_7 python3_6 -pypy -pypy3 -python3_5 -python3_7")
pip2.7 install --user xhtml2pdf
$ tree ~trac/.local/lib64/ -L 3
/mnt/data/trac/.local/lib64/
├── python2.7
│ └── site-packages
│ ├── PIL
│ ├── Pillow-6.2.1.dist-info
│ ├── PyPDF2
│ ├── PyPDF2-1.26.0-py2.7.egg-info
│ ├── reportlab
│ ├── reportlab-3.5.32.dist-info
│ ├── xhtml2pdf
│ └── xhtml2pdf-0.2.3-py2.7.egg-info
└── python3.6
└── site-packages
├── PIL
├── Pillow-6.2.1.dist-info
├── PyPDF2
├── PyPDF2-1.26.0-py3.6.egg-info
├── reportlab
├── reportlab-3.5.32.dist-info
├── xhtml2pdf
└── xhtml2pdf-0.2.3-py3.6.egg-info
Have you added the path to configuration of your web server?
Please share the configuration here if unable to solve it.
[uwsgi]
plugins = python27
chown-socket = trac:nginx
uid = trac
gid = trac
workers = 6
socket = /run/uwsgi/%n.sock
env = TRAC_ENV=/mnt/data/trac/projects/trac-pp
env = PYTHON_EGG_CACHE=/mnt/data/trac/.python-eggs
module = trac.web.main
callable = dispatch_request
How do I make uwsgi find the local python libraries such as ~/.local/lib64/python2.7/site-packages ?
pythonpath = /mnt/data/trac/.local/lib64/python2.7/site-packages