You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AttributeError: 'Babel' object has no attribute 'localeselector' #1200
VisualDL 2.4.2
Traceback (most recent call last):
File "/usr/local/bin/visualdl", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/visualdl/server/app.py", line 198, in main
_run(args)
File "/usr/local/lib/python3.8/dist-packages/visualdl/server/app.py", line 179, in _run
app = create_app(args)
File "/usr/local/lib/python3.8/dist-packages/visualdl/server/app.py", line 83, in create_app
@babel.localeselector
AttributeError: 'Babel' object has no attribute 'localeselector'
#!/usr/bin/env python3
""" A basic Flask application with one path and an HTML template. """
from flask import Flask, render_template, request
from flask_babel import Babel
class Config(object):
""" Configuration class for the Flask app. """
LANGUAGES = ["en", "fr"]
BABEL_DEFAULT_LOCALE = "en"
BABEL_DEFAULT_TIMEZONE = "UTC"
app = Flask(__name__)
babel = Babel(app)
app.config.from_object(Config)
@babel.localeselector
def get_locale():
""" Determine the locale for this user."""
return request.accept_languages.best_match(app.config["LANGUAGES"])
ّذ
@app.route('/')
def index():
""" Returns Hello world """
return render_template('2-index.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
The error
Traceback (most recent call last):
File "/home/oualid/Desktop/ALX/alx projects/alx-backend/0x02-i18n/./2-app.py", line 19, in <module>
@babel.localeselector
AttributeError: 'Babel' object has no attribute 'localeselector'
I have the same problem and I don't know what the solution is :(
Activity
lifw555 commentedon Jan 16, 2023
os: ubuntu 20.04
rainyfly commentedon Jan 16, 2023
请问您环境里 flask_babel 的版本号是多少
lifw555 commentedon Jan 16, 2023
pip list
Package Version
attrs 19.3.0
Automat 0.8.0
Babel 2.11.0
bce-python-sdk 0.8.73
blinker 1.4
certifi 2019.11.28
chardet 3.0.4
click 8.1.3
cloud-init 20.2
colorama 0.4.3
command-not-found 0.3
configobj 5.0.6
constantly 15.1.0
contourpy 1.0.7
cryptography 2.8
cycler 0.11.0
dbus-python 1.2.16
dill 0.3.6
distro 1.4.0
distro-info 0.23ubuntu1
entrypoints 0.3
Flask 2.1.3
flask-babel 3.0.0
fonttools 4.38.0
future 0.18.3
httplib2 0.14.0
hyperlink 19.0.0
idna 2.8
importlib-metadata 6.0.0
incremental 16.10.1
itsdangerous 2.1.2
Jinja2 3.1.2
jsonpatch 1.22
jsonpointer 2.0
jsonschema 3.2.0
keyring 18.0.1
kiwisolver 1.4.4
language-selector 0.1
launchpadlib 1.10.13
lazr.restfulclient 0.14.2
lazr.uri 1.0.3
MarkupSafe 2.1.1
matplotlib 3.6.3
more-itertools 4.2.0
multiprocess 0.70.14
netifaces 0.10.4
numpy 1.24.0
oauthlib 3.1.0
packaging 23.0
pandas 1.5.2
Pillow 9.4.0
pip 20.0.2
protobuf 4.21.12
pyasn1 0.4.2
pyasn1-modules 0.2.1
pycryptodome 3.16.0
PyGObject 3.36.0
PyHamcrest 1.9.0
PyJWT 1.7.1
pymacaroons 0.13.0
PyNaCl 1.3.0
pyOpenSSL 19.0.0
pyparsing 3.0.9
pyrsistent 0.15.5
pyserial 3.4
python-apt 2.0.0
python-dateutil 2.8.2
python-debian 0.1.36ubuntu1
pytz 2022.7.1
PyYAML 5.3.1
requests 2.22.0
requests-unixsocket 0.2.0
SecretStorage 2.3.1
service-identity 18.1.0
setuptools 45.2.0
simplejson 3.16.0
six 1.14.0
ssh-import-id 5.10
systemd-python 234
Twisted 18.9.0
ubuntu-advantage-tools 20.3
ufw 0.36
unattended-upgrades 0.1
urllib3 1.25.8
visualdl 2.4.2
wadllib 1.3.3
Werkzeug 2.1.2
wheel 0.34.2
zipp 1.0.0
zope.interface 4.7.1
rainyfly commentedon Jan 16, 2023
您好,我这里复现出来了,应该是最新版的flask_babel接口发生了变化,请您暂时先使用 pip install flask_babel==2.0.0 来解决这一问题
lifw555 commentedon Jan 16, 2023
收到。
rainyfly commentedon Jan 16, 2023
hi,2023.01.16 VDL依赖的flask_babel发布了新的v3.0.0版本,接口做了一个更新,如果您有相同的问题,请暂时先使用pip install flask_babel==2.0.0降级到v2.0.0版本使用。
OpenOneV commentedon May 25, 2023
有最终解决方案了吗?
rainyfly commentedon Jun 5, 2023
安装新版本的visualdl就不会出现这个问题,2.5之后的VisualDL版本适配了最新的flask_babel接口
[-]Python 3.8.10 VisualDL 2.4.2 START ERROR[/-][+]AttributeError: 'Babel' object has no attribute 'localeselector'[/+]OUALIID commentedon Feb 20, 2024
The error
I have the same problem and I don't know what the solution is :(
OUALIID commentedon Feb 20, 2024
Thank you, it worked for me and solved the problem :)
Ebuube commentedon Apr 10, 2024
Please which version of Flask is compatible with flask_babel==2.0.0
Thank you
Ebuube commentedon Apr 15, 2024
I found a solution using these requirements