The “best” way to add Python modules to Pelican? | La « meilleure » méthode pour ajouter modules Python à Pelican?

:uk:/:us: (english)

My YunoHost server

Hardware: Old laptop or computer
YunoHost version: 11.2.8.2 (stable)
I have access to my server : Through SSH | through the webadmin | direct access via keyboard / screen | … (all of it)
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no
If yes, please explain: The only tweak I did was to add /var/www/pelican/comment as an External Mount on Nextcloud following this comment and referring to the pelican-themes and pelican-plugins in my home directory, but that should not affect anything.
If your request is related to an app, specify its name and version: pelican 4.8.0~ynh1

Description of my issue

In the process of migrating my old Pelican blog to YunoHost I am met with the challenge of adding Python modules/packages that are required for certain Pelican plugins that I depend on.

So I wonder what some of the best practices would be to install these modules and ideally how to keep them updated. I assume it will have to be in venv, but not sure. I kept it pretty messy before, TBH.

For context, what I currently get when I sudo /var/www/peclican/venv/bin/pelican /var/www/pelican/content/:

[01:10:35] WARNING  Locale could not be set. Check the LOCALE setting, ensuring it is valid and available on your system.                                       log.py:89
           ERROR    Cannot load plugin `post_stats`                                                                                                             log.py:94
                    No module named 'bs4'                                                                                                                                
           ERROR    Cannot load plugin `extract_toc`                                                                                                            log.py:94
                    No module named 'bs4'                                                                                                                                
           ERROR    PIL/Pillow not found                                                                                                                        log.py:94
           WARNING  piexif not found! Cannot use exif manipulation features                                                                                     log.py:89
           WARNING  Unable to load PIL, disabling thumbnailer                                                                                                   log.py:89
           ERROR    Cannot register plugin `pelican.plugins.tipue_search`                                                                                       log.py:94
                    module 'pelican.plugins.tipue_search' has no attribute 'register'                                                                                    
[01:10:36] ERROR    Could not process Tehne/3rd-level-dotname-and-spf-trouble.markdown                                                                          log.py:94
                    '' is not a valid date                                                                                                                               
           ERROR    Could not process Tehne/new-email-address.markdown                                                                                          log.py:94
                    '' is not a valid date                                                                                                                               
[01:10:37] ERROR    Could not process Anima/tactical-intimate-dual.markdown                                                                                     log.py:94
                    '' is not a valid date                                                                                                                               
/var/www/pelican/venv/lib/python3.9/site-packages/markdown/inlinepatterns.py:297: FutureWarning: Possible nested set at position 171
  self.compiled_re = re.compile(pattern, re.DOTALL | re.UNICODE)
           WARNING  Unable to find '/Tehne/introducing-activity-aware-firefox.markdown', skipping url replacement.                                              log.py:89
Done: Processed 390 articles, 9 drafts, 0 hidden articles, 2 pages, 4 hidden pages and 0 draft pages in 4.07 seconds.


:fr: (je m’excuse pour mon mauvais français)

Mon serveur YunoHost

Matériel: Vieil ordinateur
Version de YunoHost: 11.2.8.2 (stable)
J’ai accès à mon serveur : En SSH | Par la webadmin | En direct avec un clavier/écran | … (accès complet)
Êtes-vous dans un contexte particulier ou avez-vous effectué des modificiations particulières sur votre instance ? : non
Si oui, expliquer: La seule modification que j’ai fait est ajouter /var/www/pelican/content comme un Stockage Externe en Nextcloud suivant ça et avoir pelican-themes et pelican-plugins dans mon fichier personel, mais ça ne peut rien affecter.
Si votre requête est liée à une applicatio, précisez son nom et sa version: pelican 4.8.0~ynh1

Description du problème

En migratant de mon ancient blog Pelican à YunoHost, j’ai un problème comment ajouter des modules Python, desquels certaines plugins Pelican, que j’utilise, ont besoin.

Ainsi, je vous commande des meilleures pratiques pour installer ces modules Python et, idéalement, comment les tenir à jour. Je croix que je dois utiliser venvpour ça, mais j’ai aucune idée. Précédemment, je l’ai gardé plutôt en désordre, pour être honnête.

Pour contexte, sudo /var/www/peclican/venv/bin/pelican /var/www/pelican/content/ me donne:

[01:10:35] WARNING  Locale could not be set. Check the LOCALE setting, ensuring it is valid and available on your system.                                       log.py:89
           ERROR    Cannot load plugin `post_stats`                                                                                                             log.py:94
                    No module named 'bs4'                                                                                                                                
           ERROR    Cannot load plugin `extract_toc`                                                                                                            log.py:94
                    No module named 'bs4'                                                                                                                                
           ERROR    PIL/Pillow not found                                                                                                                        log.py:94
           WARNING  piexif not found! Cannot use exif manipulation features                                                                                     log.py:89
           WARNING  Unable to load PIL, disabling thumbnailer                                                                                                   log.py:89
           ERROR    Cannot register plugin `pelican.plugins.tipue_search`                                                                                       log.py:94
                    module 'pelican.plugins.tipue_search' has no attribute 'register'                                                                                    
[01:10:36] ERROR    Could not process Tehne/3rd-level-dotname-and-spf-trouble.markdown                                                                          log.py:94
                    '' is not a valid date                                                                                                                               
           ERROR    Could not process Tehne/new-email-address.markdown                                                                                          log.py:94
                    '' is not a valid date                                                                                                                               
[01:10:37] ERROR    Could not process Anima/tactical-intimate-dual.markdown                                                                                     log.py:94
                    '' is not a valid date                                                                                                                               
/var/www/pelican/venv/lib/python3.9/site-packages/markdown/inlinepatterns.py:297: FutureWarning: Possible nested set at position 171
  self.compiled_re = re.compile(pattern, re.DOTALL | re.UNICODE)
           WARNING  Unable to find '/Tehne/introducing-activity-aware-firefox.markdown', skipping url replacement.                                              log.py:89
Done: Processed 390 articles, 9 drafts, 0 hidden articles, 2 pages, 4 hidden pages and 0 draft pages in 4.07 seconds.

Try:

sudo yunohost app shell pelican
# the line above is equivalent to `cd /var/www/pelican && sudo -u pelican bash`
source venv/bin/activate
pip3 install bs4 piexif pillow
# line above to be tweaked accordingly

when done, exit to quit the terminal or deactivate to exit the python environment for Pelican.

2 Likes

Awesome, thanks. And for updating, same but pip3 install --upgrade when needed, or is is then handled automatically on each Pelican update?

You’re welcome! Right now the upgrade script does not handle upgrading the whole environment.

1 Like

Got it. I’m not sure if it can be done safely and reliably, but if so, that would be really cool. If not, I’ll just try to remember to do it myself more regularly / when needed :slight_smile:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.