Errors - Solutions
Page content
Misc Errors and Solutions
Flask & sqlalchemy
(flask-tables-py3.10) user@host ../flask-tables> python create_fake_users.py 5
Traceback (most recent call last):
File "/Users/stoege/git/mpr_2023Q1/flask-tables/create_fake_users.py", line 6, in <module>
from bootstrap_table import User, db
File "/Users/stoege/git/mpr_2023Q1/flask-tables/bootstrap_table.py", line 18, in <module>
db.create_all()
File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 868, in create_all
self._call_for_binds(bind_key, "create_all")
File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 839, in _call_for_binds
engine = self.engines[key]
File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 628, in engines
app = current_app._get_current_object() # type: ignore[attr-defined]
File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/werkzeug/local.py", line 513, in _get_current_object
raise RuntimeError(unbound_message) from None
RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.
https://stackoverflow.com/questions/34122949/working-outside-of-application-context-flask
Solution - Downgrade flask-sqlalchemy to 2.5.1
# Downgrade Flask Version
gsed -i 's/flask-sqlalchemy.*/flask-sqlalchemy = "~2.5.1"/' pyproject.toml
# Rebuild Lock
poetry lock
# Install Packages
poetry install
# run again
python create_fake_users.py 5
Gitlab on Vultr
Created a Gitlab Instance on Vultr for testing Reason. Seems all fine, except:
root@gitlab:~# apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu focal-security InRelease
Get:2 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
Err:2 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease
The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
Fetched 23.3 kB in 2s (11.0 kB/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease: The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
W: Failed to fetch https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/focal/InRelease The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
W: Some index files failed to download. They have been ignored, or old ones used instead.
Solution
curl -s https://packages.gitlab.com/gpg.key | apt-key add -
apt-get update
apt-get upgrade
Selfsigned Cert
gitlab has got a selfsigned cert on gitlab sever. like to change this.
cd /etc/gitlab/
cp gitlab.rb gitlab.rb.bak
sed -i 's/^external_url.*/external_url "https:\/\/gitlab.your.domain.net"/' gitlab.rb
sed -i "s/^# letsencrypt\['auto_renew'\].*/letsencrypt['auto_renew'] = true/" gitlab.rb
sed -i "s/^# letsencrypt\['contact_emails'\].*/letsencrypt['contact_emails'] = ['domains@your.domain.net']/" gitlab.rb
git diff gitlab.rb.*
gitlab-ctl reconfigure
Airflow Root Login
you have Airflow running on Docker and not root login ?
docker exec -u root -ti airflow-airflow-scheduler-1 bash
then, you can install all the stuff you need and fix your problems
apt-get update
apt-get upgrade
apt-get install htop lsof tree procps tcpdump net-tools mlocate dnsutils
updatedb
cron & poetry
you wanna run a python script via poetry as cronjob and you get the following error:
# cronjob as root
* * * * * cd /path/to/your/script; poetry run mycode > out 2>&1
# error
Traceback (most recent call last):
File "/usr/local/bin/poetry", line 5, in <module>
from poetry.console.application import main
File "/usr/local/lib/python3.9/site-packages/poetry/console/application.py", line 19, in <module>
from poetry.__version__ import __version__
File "/usr/local/lib/python3.9/site-packages/poetry/__version__.py", line 5, in <module>
from poetry.utils._compat import metadata
File "/usr/local/lib/python3.9/site-packages/poetry/utils/_compat.py", line 20, in <module>
import importlib_metadata as metadata
File "/usr/local/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 6, in <module>
import zipp
ModuleNotFoundError: No module named 'zipp'
# fix -> set HOME as the Virtual Env is located here
* * * * * export HOME=/root; cd /path/to/your/script; poetry run mycode > out 2>&1
Any Comments ?
sha256: 544f583153ef22c57986f77c05e773d507c695bac36353a08c02e7ad4548704f