openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.

Home Page:https://openfisca.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install from scratch not working due to jinja transitive upgrade

MichaelBitard opened this issue · comments

Hi there!

I really enjoy OpenFisca, but I recently encountered an issue.

Here is what I did:

pip install --upgrade pip twine wheel
pip install openfisca-core[web-api]
pip install openfisca-france-fiscalite-miniere

openfisca serve --country-package openfisca_france_fiscalite_miniere

Here is what I expected to happen:

The server should be up and running

Here is what actually happened:

A lot of stacktraces with some jinjja escape error:

Traceback (most recent call last):
  File "/usr/local/bin/openfisca", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/openfisca_core/scripts/openfisca_command.py", line 64, in main
    from openfisca_web_api.scripts.serve import main
  File "/usr/local/lib/python3.7/site-packages/openfisca_web_api/scripts/serve.py", line 7, in <module>
    from openfisca_web_api.app import create_app
  File "/usr/local/lib/python3.7/site-packages/openfisca_web_api/app.py", line 17, in <module>
    handle_import_error(error)
  File "/usr/local/lib/python3.7/site-packages/openfisca_web_api/errors.py", line 9, in handle_import_error
    raise ImportError("OpenFisca is missing some dependencies to run the Web API: '{}'. To install them, run `pip install openfisca_core[web-api]`.".format(error))
ImportError: OpenFisca is missing some dependencies to run the Web API: 'cannot import name 'escape' from 'jinja2' (/usr/local/lib/python3.7/site-packages/jinja2/__init__.py)'. To install them, run `pip install op
enfisca_core[web-api]`.

Here is data (or links to it) that can help you reproduce this issue:

I was able to fix this by upgrading flask to the 2.1.2 version (in the setup.py it's the 1.1.4 specified)

I'm not sure this is the correct fix though, but from stackoverflow here: https://stackoverflow.com/questions/71718167/importerror-cannot-import-name-escape-from-jinja2 this may indeed be the root cause

Context

I identify more as a:

  • Developer (I create tools that use the existing OpenFisca code).

Thanks @MichaelBitard for opening this issue! A proper fix for this problem needs a full update of many dependencies, which is underway in branch upgrade-python-numpy.

Some other contributors deployed a workaround in branch msa_temp_jinja2_fix, which could be of use too.

If you identified the main culprit as flask, could you please open a PR with your fix? We could thus run all tests on it and potentially deploy it faster than the full dependencies update will 😃

Works on latest versions of openfisca!