Cannot init the db for Airflow - airflow

I have some experience starting starting up Apache Airflow but I have now an error when I try to airflow db init command. The error is as below. I am running Airflow on virtual env with Python 3.8. Any help would appreciated. I am not sure to understand this error as I managed to init the db without importing any _cffi_backend module in the past.
The error:
airflow) airflow#26c8ed88c008:~/airflow$ airflow db init
Traceback (most recent call last):
File "/home/airflow/.local/bin/airflow", line 8, in <module>
sys.exit(main())
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/__main__.py", line 40, in main
args.func(args)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/cli_parser.py", line 47, in command
func = import_string(import_path)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/module_loading.py", line 32, in import_string
module = import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/db_command.py", line 24, in <module>
from airflow.utils import cli as cli_utils, db
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/db.py", line 26, in <module>
from airflow.jobs.base_job import BaseJob # noqa: F401
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/__init__.py", line 19, in <module>
import airflow.jobs.backfill_job
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/backfill_job.py", line 29, in <module>
from airflow import models
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/__init__.py", line 20, in <module>
from airflow.models.baseoperator import BaseOperator, BaseOperatorLink
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py", line 59, in <module>
from airflow.models.taskinstance import Context, TaskInstance, clear_task_instances
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 57, in <module>
from airflow.models.variable import Variable
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/variable.py", line 24, in <module>
from cryptography.fernet import InvalidToken as InvalidFernetToken
File "/usr/lib/python3/dist-packages/cryptography/fernet.py", line 17, in <module>
from cryptography.hazmat.primitives import hashes, padding
File "/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/padding.py", line 13, in <module>
from cryptography.hazmat.bindings._padding import lib
ModuleNotFoundError: No module named '_cffi_backend'

Airflow 2 has hard requirement on cryptography module being installed and operating. So you have to install it properly. There are some distributions of Linux that you need to add some additional packages to make it works.
You can take a look at this query and similar problems and possibly you will find out how cryptography can be installed or reinstalled cleanly.
No module named _cffi_backend

Check the installation docs for cryptography: https://cryptography.io/en/latest/installation/
If you are using Alpine, make sure you install the following:
$ sudo apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
Similarly for Debian/buster:
$ sudo apt-get install build-essential libssl-dev libffi-dev \
python3-dev cargo
Check their installation guide for other distros and run airflow db init again

Related

Jupyter notebook, anaconda not launching after python upgrade

Error while launching jupyter notebook from terminal
Traceback (most recent call last):
File "/Users/mukhtadirsyed/opt/anaconda3/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
File "/Users/mukhtadirsyed/opt/anaconda3/lib/python3.9/site-packages/notebook/notebookapp.py", line 79, in <module>
from .services.contents.manager import ContentsManager
File "/Users/mukhtadirsyed/opt/anaconda3/lib/python3.9/site-packages/notebook/services/contents/manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "/Users/mukhtadirsyed/opt/anaconda3/lib/python3.9/site-packages/nbformat/__init__.py", line 32, in <module>
from .validator import validate, ValidationError
File "/Users/mukhtadirsyed/opt/anaconda3/lib/python3.9/site-packages/nbformat/validator.py", line 12, in <module>
from .json_compat import get_current_validator, ValidationError
File "/Users/mukhtadirsyed/opt/anaconda3/lib/python3.9/site-packages/nbformat/json_compat.py", line 10, in <module>
import jsonschema
File "/Users/mukhtadirsyed/opt/anaconda3/lib/python3.9/site-packages/jsonschema/__init__.py", line 22, in <module>
from jsonschema.protocols import Validator
ModuleNotFoundError: No module named 'jsonschema.protocols'
My python version is 3.9.7
tried to install anaconda again but that failed too

unable to start ride.py

i am very new in this topic. i want to learn more about automation. so i came across the robotframework during my search. the installation of the robotframework worked but when i want to start "ride.py" it gives me this output. am i right that the command "ride.py" should open an IDE where i can start scripting? But i just get this output. Can ya please help me what i did wrong.
i use the OS Ubuntu on a VM
w#w-Virtual-Machine:~$ ride.py
Traceback (most recent call last):
File "/home/w/.local/bin/ride.py", line 21, in <module>
from robotide import main
File "/home/w/.local/lib/python3.10/site-packages/robotide/__init__.py", line 59, in <module>
from robotide.utils import PY2, PY3
File "/home/w/.local/lib/python3.10/site-packages/robotide/utils/__init__.py", line 21, in <module>
import robotide.lib.robot.utils
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/__init__.py", line 44, in <module>
from robotide.lib.robot.rebot import rebot, rebot_cli
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/rebot.py", line 40, in <module>
from robotide.lib.robot.conf import RebotSettings
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/conf/__init__.py", line 27, in <module>
from .settings import RobotSettings, RebotSettings
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/conf/settings.py", line 22, in <module>
from robotide.lib.robot.output import LOGGER, loggerhelper
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/output/__init__.py", line 22, in <module>
from .output import Output
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/output/output.py", line 16, in <module>
from . import pyloggingconf
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/output/pyloggingconf.py", line 19, in <module>
from robotide.lib.robot.utils import get_error_details, unic
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/utils/__init__.py", line 36, in <module>
from .argumentparser import ArgumentParser, cmdline2list
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/utils/argumentparser.py", line 28, in <module>
from .misc import plural_or_not
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/utils/misc.py", line 21, in <module>
from .robottypes import is_integer
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/utils/robottypes.py", line 25, in <module>
from .robottypes3 import (is_bytes, is_dict_like, is_integer, is_list_like,
File "/home/w/.local/lib/python3.10/site-packages/robotide/lib/robot/utils/robottypes3.py", line 16, in <module>
from collections import Mapping, UserString
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
You don't mention how you installed RIDE, and I am even surprised it was installed if from PyPi.
Only on today's date (24-june-2022), a development version was updated to run on Python 3.10 (maybe). You can try to install, this one, but be aware of its new bugs.
I can install with:
pip install -U https://github.com/robotframework/RIDE/archive/master.zip
You should browse the RIDE project page here, and look at README, CHANGELOG and Issues. Also see the Slack and Forum links.

importlib.metadata.PackageNotFoundError: regex while building an .exe with pyinstaller

I am trying to build an executable with pyinstaller and I am getting the following errors:
Traceback (most recent call last):
File "transformers/utils/versions.py", line 105, in require_version
File "importlib/metadata.py", line 551, in version
File "importlib/metadata.py", line 524, in distribution
File "importlib/metadata.py", line 187, in from_name
importlib.metadata.PackageNotFoundError: regex
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "chatbot2.py", line 8, in <module>
File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
File "transformers/__init__.py", line 43, in <module>
File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
File "transformers/dependency_versions_check.py", line 41, in <module>
File "transformers/utils/versions.py", line 120, in require_version_core
File "transformers/utils/versions.py", line 107, in require_version
importlib.metadata.PackageNotFoundError: The 'regex!=2019.12.17' distribution was not found and is required by this application.
Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git master
[30391] Failed to execute script 'chatbot2' due to unhandled exception!
I am using PyInstaller version 5.0.dev0 and Python version 3.9.1.
I tried pip3.9 install transformers, pip3.9 install regex, I tried adding hooks hook-regex.py and hook-transformers.py.
I would really appreciate any suggestions! Thank you!

import nltk eror, No module named '_sqlite3'

I'm in ubuntu, python 3.7.6
here what i do:
sudo apt-get install sqlite-devel
sudo apt-get install libsqlite3-dev
sudo pip3 install pysqlite
python3 -m pip install --user -U pysqlite3
I try to import nltk library.
line (1): import nltk
Traceback (most recent call last):
File "chat.py", line 1, in <module>
import nltk
File "/usr/local/lib/python3.7/site-packages/nltk/__init__.py", line 150, in <module>
from nltk.translate import *
File "/usr/local/lib/python3.7/site-packages/nltk/translate/__init__.py", line 23, in <module>
from nltk.translate.meteor_score import meteor_score as meteor
File "/usr/local/lib/python3.7/site-packages/nltk/translate/meteor_score.py", line 10, in <module>
from nltk.stem.porter import PorterStemmer
File "/usr/local/lib/python3.7/site-packages/nltk/stem/__init__.py", line 29, in <module>
from nltk.stem.snowball import SnowballStemmer
File "/usr/local/lib/python3.7/site-packages/nltk/stem/snowball.py", line 32, in <module>
from nltk.corpus import stopwords
File "/usr/local/lib/python3.7/site-packages/nltk/corpus/__init__.py", line 66, in <module>
from nltk.corpus.reader import *
File "/usr/local/lib/python3.7/site-packages/nltk/corpus/reader/__init__.py", line 105, in <module>
from nltk.corpus.reader.panlex_lite import *
File "/usr/local/lib/python3.7/site-packages/nltk/corpus/reader/panlex_lite.py", line 15, in <module>
import sqlite3
File "/usr/local/lib/python3.7/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
can some one help me with this?
Thanks for your time !
Edit (26.03.2020)
sqlite3 -version:
3.32.0 2020-03-12 17:54:39 ea914bec81c49625072fc9d23faa048300f3a0421e069d303b7203edcdfb3743
I downgrade my python too 3.6 and it works!

pkg_resources.DistributionNotFound: distribute error on new Plone 4.3 instance

I've just installed a new plone 4.3 instance in a folder which already contained 2 Plone 4.3 instance, which both work fine. When I try to run buildout I get this error:
Traceback (most recent call last):
File "bin/buildout", line 17, in <module>
import zc.buildout.buildout
File "/usr/local/Plone4.3/buildout-cache/eggs/zc.buildout-1.7.1-py2.7.egg/zc/buildout/buildout.py", line 40, in <module>
import zc.buildout.download
File "/usr/local/Plone4.3/buildout-cache/eggs/zc.buildout-1.7.1-py2.7.egg/zc/buildout/download.py", line 20, in <module>
from zc.buildout.easy_install import realpath
File "/usr/local/Plone4.3/buildout-cache/eggs/zc.buildout-1.7.1-py2.7.egg/zc/buildout/easy_install.py", line 31, in <module>
import setuptools.package_index
File "/usr/local/Plone4.3/Python-2.7/lib/python2.7/site-packages/distribute-0.6.35-py2.7.egg/setuptools/package_index.py", line 158, in <module>
sys.version[:3], require('distribute')[0].version
File "/usr/local/Plone4.3/buildout-cache/eggs/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 666, in require
continue # try the next older version of project
File "/usr/local/Plone4.3/buildout-cache/eggs/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: distribute
Google has failed me. Can anyone tell me how to resolve this error?

Resources