trac-admin changeset added failing: No module named markupsafe

55 views
Skip to first unread message

Mo

unread,
Oct 14, 2020, 12:35:54 PM10/14/20
to Trac Users
Hello,

we are running Trac-1.4.
Because most of the Python2.7 is going to be dropped from distributions, we have migrated to a local python2.7 in $HOME and installed all dependencies for Trac with pip2 in $HOME.

One thing that is still failing is this command:

$ trac-admin /mnt/data/trac/projects/trac-pp/ changeset added mt6 c4edcac1
Traceback (most recent call last):
 
File "/mnt/data/trac/.local/bin/trac-admin", line 5, in <module>
   
from trac.admin.console import run
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/trac/admin/__init__.py", line 14, in <module>
   
from trac.admin.api import *
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/trac/admin/api.py", line 20, in <module>
   
from trac.util.text import levenshtein_distance
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/trac/util/__init__.py", line 47, in <module>
   
from trac.util.datefmt import time_now, to_datetime, to_timestamp, utc
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/trac/util/datefmt.py", line 52, in <module>
   
from trac.util.text import to_unicode, getpreferredencoding
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/trac/util/text.py", line 30, in <module>
   
import jinja2
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/jinja2/__init__.py", line 33, in <module>
   
from jinja2.environment import Environment, Template
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/jinja2/environment.py", line 15, in <module>
   
from jinja2 import nodes
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/jinja2/nodes.py", line 19, in <module>
   
from jinja2.utils import Markup
 
File "/mnt/data/trac/.local/lib64/python2.7/site-packages/jinja2/utils.py", line 642, in <module>
   
from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe

I tried

pip2 install --user MarkupSafe

but it seems this is not the required module.
What is missing here?

Best regards,
Mo

RjOllos

unread,
Oct 14, 2020, 12:42:06 PM10/14/20
to Trac Users
What does "pip2 list" show?

Markupsafe is a jinja2 dependency:

Is Markupsafe in /mnt/data/trac/.local/lib64/python2.7/site-packages?

Seems like your python path may be broken.

Ryan 

Mo

unread,
Oct 14, 2020, 12:51:39 PM10/14/20
to Trac Users
RjOllos schrieb am Mittwoch, 14. Oktober 2020 um 18:42:06 UTC+2:
What does "pip2 list" show?

Markupsafe is a jinja2 dependency:

Is Markupsafe in /mnt/data/trac/.local/lib64/python2.7/site-packages?

Seems like your python path may be broken.

Ryan 

I see.
After I installed python2.7 and pip2 locally in $HOME, I have pip2 again, which was dropped by the Linux distribution.
But now, pip2 does not see my packages anymore:

$ pip2 list --user 2>/dev/null
Package    Version
---------- -------
MarkupSafe 1.1.1

My old pip2 has installed to

$ ls  ~/.local/lib64/python2.7/site-packages/
acct_mgr
autocompleteusers
coderev
componentdependencies
estimationtools
fabfile
genshi
Genshi-0.7.3-py2.7.egg-info
httpauth
importexportxls
...

~Mo

RjOllos

unread,
Oct 14, 2020, 1:01:15 PM10/14/20
to Trac Users
Looks similar to your previous issue:

I would try:

$ PYTHONPATH=/mnt/data/trac/.local/lib64/python2.7/site-packages pip2 list

Or you might need to use "/mnt/data/trac/.local/lib64/python2.7"

If that works, then PYTHONPATH is the problem.

Ryan

Mo

unread,
Oct 14, 2020, 1:37:16 PM10/14/20
to Trac Users
RjOllos schrieb am Mittwoch, 14. Oktober 2020 um 19:01:15 UTC+2:
Looks similar to your previous issue:

I would try:

$ PYTHONPATH=/mnt/data/trac/.local/lib64/python2.7/site-packages pip2 list

Looks like.
This works.

However for uwsgi I have already set the PYTHONPATH.
That "trac-admin changeset added..."  is called from a cronjob script or manually for new changesets.
How would I set the $PYTHONPATH? It is currently not set. Nothing in /etc is setting this variable currently. How is it determined, configured at build time of python? I can set it in ~/.bash_profile, but then I must take care if sourced for interactive shells or for all, because there are these cronjobs as well.

However it seems that my old pip2 --user installed by distribution was installing to ~/.local/lib64/python2.7/site-packages and the new pip2 locally installed at ~/bin/pip2 is installing to ~/.local/lib/python2.7/site-packages.

I would prefer merging all to the new location and not setting the PYTHONPATH, adapting in uwsgi.conf
What do you think?

~Mo

RjOllos

unread,
Oct 14, 2020, 1:49:44 PM10/14/20
to Trac Users
Yeah, if your python is installed to  ~/bin, and it's system packages is ~/lib/python2.7/site-packages, I would install all packages there rather than using the "--user" flag with "pip install".

Ryan

Mo

unread,
Oct 15, 2020, 8:01:56 AM10/15/20
to Trac Users
I got that fixed by installing everying like pip, setuptools, Trac and plugins and uWSGI inside a virtualenv. After that I made a copy of my system uwsgi-init-script and changed UWSGI_EXEC to use the virtualenv uwsgi executable.
Reply all
Reply to author
Forward
0 new messages