airflow initdb failed: ImportError: No module name

2019-07-25 18:59发布

问题:

I had airflow 1.7.0 installed on a machine where I don't have root access. Everything is installed in /apps/dist/ for which I'm the owner

Ran

$ pip install apache-airflow

I had a lot of success, until this:

Installing collected packages: webencodings, html5lib, bleach, configparser, flask-wtf, future, gunicorn, apache-airflow
  Found existing installation: Flask-WTF 0.12
    Uninstalling Flask-WTF-0.12:
      Successfully uninstalled Flask-WTF-0.12
  Found existing installation: future 0.15.2
    Uninstalling future-0.15.2:
      Successfully uninstalled future-0.15.2
  Found existing installation: gunicorn 19.3.0
    Uninstalling gunicorn-19.3.0:
      Successfully uninstalled gunicorn-19.3.0
Exception:
Traceback (most recent call last):
  File "/apps/dist/python/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/apps/dist/python/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/apps/dist/python/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/apps/dist/python/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/apps/dist/python/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/apps/dist/python/lib/python2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/apps/dist/python/lib/python2.7/site-packages/pip/wheel.py", line 329, in clobber
    os.utime(destfile, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/apps/dist/python/lib/python2.7/site-packages/airflow/configuration.py'
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

So I took their advice, and upgraded pip:

$ pip install --upgrade pip
Collecting pip
  Downloading pip-9.0.3-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 826kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-9.0.3

So then I re-ran pip install apache-airflow, and got 57 lines of "Requirement already satisfied". Next step:

$ airflow initdb
Traceback (most recent call last):
  File "/apps/dist/python/bin/airflow", line 17, in <module>
    from airflow import configuration
  File "/apps/dist/python/lib/python2.7/site-packages/airflow/__init__.py", line 29, in <module>
    from airflow import configuration as conf
  File "/apps/dist/python/lib/python2.7/site-packages/airflow/configuration.py", line 31, in <module>
    from airflow.utils.log.logging_mixin import LoggingMixin
ImportError: No module named log.logging_mixin

I searched for "ImportError: No module named log.logging_mixin", and got a bunch of hits discussion logging. So I searched for ImportError: No module named "log.logging_mixin", and got essentially no hits.

What am I missing?

回答1:

So, the problem is that pip overestimates when it's finished.

I uninstalled airflow, then reinstalled it, and pip complained about the presence of /apps/dist/python/bin/airflow

Uninstalled again, deleted /apps/dist/python/bin/airflow, reinstalled, and now everything works