fame icon indicating copy to clipboard operation
fame copied to clipboard

Error at install due to the version of Flask

Open Heat-Miser opened this issue 2 years ago • 3 comments

Description

hello

the installation scripts fails with an error linked to a Flask dependency

ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/opt/fame/env/lib/python3.7/site-packages/markupsafe/__init__.py)

According to my research this is due to a modification in one of the dependencies (markupsafe) used by Flask which has removed the support for "soft_unicode".

Here is the full stacktrace

Steps to Reproduce

I discovered that problem while trying to make the docker image on a recent version of Debian with python3. When running the installation script, the installation stops and this error is displayed.

Expected behavior

Well the installation script should work :)

Actual behavior

Here is the full stacktrace

root@50565fcff0cc:/opt/fame# ./docker/launch.sh 
[ ok ] Starting Docker: docker.
[+] Using existing virtualenv.

[+] Installing requirements ...
[?] MongoDB host [localhost]: 
[?] MongoDB port [27017]: 
[?] MongoDB database [fame]: 

Choose your installation type:

 - 1: Web server + local worker
 - 2: Remote worker

[?] Installation type [1]: 
Traceback (most recent call last):
  File "utils/install.py", line 224, in <module>
    main()
  File "utils/install.py", line 218, in main
    perform_local_installation(context)
  File "utils/install.py", line 133, in perform_local_installation
    templates = Templates()
  File "utils/install.py", line 17, in __init__
    from jinja2 import Environment, FileSystemLoader
  File "/opt/fame/env/lib/python3.7/site-packages/jinja2/__init__.py", line 12, in <module>
    from .environment import Environment
  File "/opt/fame/env/lib/python3.7/site-packages/jinja2/environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "/opt/fame/env/lib/python3.7/site-packages/jinja2/defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "/opt/fame/env/lib/python3.7/site-packages/jinja2/filters.py", line 13, in <module>
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/opt/fame/env/lib/python3.7/site-packages/markupsafe/__init__.py)

Solutions

Two solutions can be considered:

  • we can upgrade the dependencies to the latest versions of Flask, I've tested it, it works and Fame seems to be okay, but I didn't spend too much time trying everything
  • the other solution, less risky, could be to add in the requirements.txt file a specific version of markupsafe, the 2.0.1 which still has the support for soft_unicode: markupsafe==2.0.1

what do you think ?

Heat-Miser avatar Mar 28 '22 12:03 Heat-Miser

I would go with the update of Flask and this may already be happening in this PR.

gaelmuller avatar Mar 29 '22 08:03 gaelmuller

Ah damned I missed that PR I was working on updating the docker image on my side too :)

I'm gonna test it. Thanks, I'll close the issue just after.

Heat-Miser avatar Mar 29 '22 08:03 Heat-Miser

Since you are working on docker image...Fyi, If you want to test the PR before it get merged:

git clone https://github.com/Augustin-FL/fame
cd fame/docker
git checkout use_env

sed -i 's+git clone https://github.com/certsocietegenerale/fame+git clone https://github.com/Augustin-FL/fame \&\& cd fame \&\& git checkout use_env \&\& cd ..+g' Dockerfile 

cp fame.env.template fame.env
docker-compose up --build

Augustin-FL avatar Mar 30 '22 08:03 Augustin-FL

Hi,

Flask has been bumped to 2.x, it should be ok now

Augustin-FL avatar Aug 12 '22 08:08 Augustin-FL