No module named 'airflow' when initializing Apache airflow docker - docker-compose

I am trying to run apache airflow as a docker on a Centos 7 machine.
I followed all the instructions here:https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html
when i am trying to initialize the docker by running docker-compose up airflow-init
i am getting this error
[root#centos7 centos]# docker-compose up airflow-init
Creating network "centos_default" with the default driver
Creating volume "centos_postgres-db-volume" with default driver
Creating centos_redis_1 ... done
Creating centos_postgres_1 ... done
Creating centos_airflow-init_1 ... done
Attaching to centos_airflow-init_1
airflow-init_1 | BACKEND=postgresql+psycopg2
airflow-init_1 | DB_HOST=postgres
airflow-init_1 | DB_PORT=5432
airflow-init_1 |
airflow-init_1 | Traceback (most recent call last):
airflow-init_1 | File "/home/airflow/.local/bin/airflow", line 5, in <module>
airflow-init_1 | from airflow.__main__ import main
airflow-init_1 | ModuleNotFoundError: No module named 'airflow'
airflow-init_1 | Traceback (most recent call last):
airflow-init_1 | File "/home/airflow/.local/bin/airflow", line 5, in <module>
airflow-init_1 | from airflow.__main__ import main
airflow-init_1 | ModuleNotFoundError: No module named 'airflow'
airflow-init_1 | Traceback (most recent call last):
airflow-init_1 | File "/home/airflow/.local/bin/airflow", line 5, in <module>
airflow-init_1 | from airflow.__main__ import main
airflow-init_1 | ModuleNotFoundError: No module named 'airflow'
airflow-init_1 | Traceback (most recent call last):
airflow-init_1 | File "/home/airflow/.local/bin/airflow", line 5, in <module>
airflow-init_1 | from airflow.__main__ import main
airflow-init_1 | ModuleNotFoundError: No module named 'airflow'
airflow-init_1 | Traceback (most recent call last):
airflow-init_1 | File "/home/airflow/.local/bin/airflow", line 5, in <module>
airflow-init_1 | from airflow.__main__ import main
airflow-init_1 | ModuleNotFoundError: No module named 'airflow'
centos_airflow-init_1 exited with code 1
i used the standard YAML file from here:https://airflow.apache.org/docs/apache-airflow/2.0.1/docker-compose.yaml
i found that it's a known issue here:https://github.com/apache/airflow/issues/14520
but i could not understand how to solve this problem.
any advice?

I solved this problem this way.
login with a non-root user.
find your user id :
echo $UID
create .env file and put these lines inside it . replace 4003 with your user id:
AIRFLOW_UID=4003
AIRFLOW_GID=0
If you have not created these directories, first create these and run docker-compose:
sudo mkdir ./dags ./logs ./plugins
sudo chmod 777 -R logs
sudo docker-compose up airflow-init
sudo docker-compose up

I found the problem.
There is a bug on version 2.0.1 that doesn’t let you run the airflow containers using root.
You have to run the installation under another user name (with sudo).

This can happen if AIRFLOW_GID is not set properly in the .env file.
The instructions include running the command echo -e "AIRFLOW_UID=$(id -u)\nAIRFLOW_GID=0" > .env.
To check this worked as expected, look at the contents of the .env file by running cat .env.
You should see something that looks like this:
AIRFLOW_UID=1000
AIRFLOW_GID=0
If you do not you might need to manually edit the .env file to set the airflow uid and gid.

Related

Run Redis Insights in Docker Compose

I'm trying to run Redis Insight in Docker Compose and I always get errors even though the only thing I'm changing from the Docker Run command is the volume. How do I fix this?
docker-compose.yml
redisinsights:
image: redislabs/redisinsight:latest
restart: always
ports:
- '8001:8001'
volumes:
- ./data/redisinsight:/db
logs
redisinsights_1 | Process 9 died: No such process; trying to remove PID file. (/run/avahi-daemon//pid)
redisinsights_1 | Traceback (most recent call last):
redisinsights_1 | File "./entry.py", line 11, in <module>
redisinsights_1 | File "./startup.py", line 47, in <module>
redisinsights_1 | File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
redisinsights_1 | self._setup(name)
redisinsights_1 | File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
redisinsights_1 | self._wrapped = Settings(settings_module)
redisinsights_1 | File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
redisinsights_1 | mod = importlib.import_module(self.SETTINGS_MODULE)
redisinsights_1 | File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
redisinsights_1 | return _bootstrap._gcd_import(name[level:], package, level)
redisinsights_1 | File "./redisinsight/settings/__init__.py", line 365, in <module>
redisinsights_1 | File "/usr/local/lib/python3.6/os.py", line 220, in makedirs
redisinsights_1 | mkdir(name, mode)
redisinsights_1 | PermissionError: [Errno 13] Permission denied: '/db/rsnaps'
Follow the below steps to make it work:
Step 1. Create a Docker Compose file as shown below:
version: '3'
services:
redis:
image: redislabs/redismod
ports:
- 6379:6379
redisinsight:
image: redislabs/redisinsight:latest
ports:
- '8001:8001'
volumes:
- ./Users/ajeetraina/data/redisinsight:/db
Step 2. Provide sufficient permission
Go to Preference under Docker Desktop > File Sharing and add your folder structure which you want to share.
Please change the directory structure as per your environment
Step 3. Execute the Docker compose CLI
docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------------
pinegraph_redis_1 redis-server --loadmodule ... Up 0.0.0.0:6379->6379/tcp
pinegraph_redisinsight_1 bash ./docker-entry.sh pyt ... Up 0.0.0.0:8001->8001/tcp
Go to web browser and open RedisInsight URL.
Enjoy!
I was having the same problem on a Linux machine. I was able to solve it through the Installing RedisInsight on Docker
page of redis.
Note: Make sure the directory you pass as a volume to the container
has necessary permissions for the container to access it. For example,
if the previous command returns a permissions error, run the following
command:
console $ chown -R 1001 redisinsight

Ubuntu 16.04 -ModuleNotFoundError: No module named 'apt_pkg'

I am trying to run this line of code
$ sudo add-apt-repository 'deb [arch=amd64,arm64,i386,ppc64el] http://mariadb.mirror.liquidtelecom.com/repo/10.5/ubuntu xenial main'
I am getting an error-
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 12, in
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I have tried multiple solutions , nothing seems to work

Aws Cloudwatch Logs agent throws an error

I'm setting up awslogs agent on ec2 instance, When i run the python script of awslogs. I'm getting below message.
Downloading the latest CloudWatch Logs agent bits ... ERROR: Failed to create virtualenv. Try manually installing with pip and adding it to the sudo user's PATH before running this script.
And awslogs-agent-setup.log show below error.
Environment: CentOS 6.10 and Python 2.6
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/lib/python2.6/site-packages/pip-19.0.3-py2.6.egg/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/usr/lib/python2.6/site-packages/pip-19.0.3-py2.6.egg/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/lib/python2.6/site-packages/pip-19.0.3-py2.6.egg/pip/_vendor/urllib3/connectionpool.py", line 92
_blocking_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}
^
SyntaxError: invalid syntax
/usr/bin/virtualenv
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 7, in <module>
from virtualenv import main
File "/usr/lib/python2.6/site-packages/virtualenv.py", line 51, in <module>
print("ERROR: {}".format(sys.exc_info()[1]))
ValueError: zero length field name in format
Basically, this error is due to your python version 2.6. Could you please update your python version from 2.6 to 2.7 or 3.1.
This should help.

Error while installing Flutter in Linux

I set the path variable and echo the path and it give me expected output
uttu#Lore-UK:~/flutter$ export PATH=`pwd`/flutter/bin:$PATH
uttu#Lore-UK:~/flutter$ echo $PATH
/home/uttu/flutter/flutter/bin:/home/uttu/home/flutter/bin:/home/uttu/flutter/flutter/bin:/home/uttu/home/flutter/bin:/home/uttu/.local/share/umake/bin:/home/uttu/bin:/home/uttu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
but when I ran flutter doctor it show
$ flutter doctor
Traceback (most recent call last):
File "/usr/lib/python3.5/dbm/gnu.py", line 4, in <module>
from _gdbm import *
ImportError: No module named '_gdbm'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "/usr/lib/python3.5/dbm/gnu.py", line 6, in <module>
raise ImportError(str(msg) + ', please install the python3-gdbm package')
ImportError: No module named '_gdbm', please install the python3-gdbm package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
File "/usr/lib/python3/dist-packages/CommandNotFound/__init__.py", line 3, in <module>
from CommandNotFound.CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 9, in <module>
import gdbm
ImportError: No module named 'gdbm'
I am not able to understand why I am getting this error and how to solve it
Thank you in advance
As you can see in your error message you are missing the module 'gdbm' as it says here:
please install the python3-gdbm package
Try installing this module and running flutter doctor again.
Other people have had the same problem Here

Docker-compose ps error

I am new to docker-compose and getting the following error when I type in docker-compose ps.
Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 7, in <module>
from compose.cli.main import main
File "/Library/Python/2.7/site-packages/compose/cli/main.py", line 20, in <module>
from ..bundle import get_image_digests
File "/Library/Python/2.7/site-packages/compose/bundle.py", line 14, in <module>
from .service import format_environment
File "/Library/Python/2.7/site-packages/compose/service.py", line 37, in <module>
from .parallel import parallel_execute
File "/Library/Python/2.7/site-packages/compose/parallel.py", line 10, in <module>
from six.moves import _thread as thread
ImportError: cannot import name _thread
Docker-compose is written by python. It seems that you miss some python packages. You can refer to the following page of how to fix the python lib issue.
Matplotlib issue on OS X ("ImportError: cannot import name _thread")
Alternatively, you can try to install docker-compose as a container, the docker container contains appropriate environment for docker-compose.
https://docs.docker.com/compose/install/#install-as-a-container