Airflow: ImportError: No module named configparser - python

Environment: Python 2.7.5 & Centos 7
I have successfully installed airflow using:
pip install apache-airflow
But when I run
airflow initdb,
it says:
Traceback (most recent call last):
File "/usr/bin/airflow", line 21, in <module>
from airflow import configuration
File "/usr/lib/python2.7/site-packages/airflow/__init__.py", line 35, in <module>
from airflow import configuration as conf
File "/usr/lib/python2.7/site-packages/airflow/configuration.py", line 38, in <module>
from backports.configparser import ConfigParser
ImportError: No module named configparser
What am I missing?

The issue is you have installed a wrong package. airflow was renamed to apache-airflow from 1.8.1. The website you used has outdated docs.
Please install using the following command
export AIRFLOW_GPL_UNIDECODE=yes
pip install apache-airflow
This should install 1.10.0 which is the latest stable version and resolve your issues.

Related

tensorflow module not found, while using streamlit

PS D:\projects\fashion-recommender-system> streamlit run main1.py
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://192.168.1.213:8501
2022-05-04 14:12:41.903 Traceback (most recent call last):
File "C:\Users\prana\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\streamlit\scriptrunner\script_runner.py", line 443, in run_script
exec(code, module.dict)
File "D:\projects\fashion-recommender-system\main1.py", line 1, in
import tensorflow
File "C:\Users\prana\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tensorflow_init.py", line 37, in
from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python'
above is the output of terminal.
tensorflow is installed in python and does work when I run python file, but when I run the python file using streamlit run main.py, It doesn't find any tensorflow module.
I have installed python versions of 3.9 and 3.7
In 3.7 python shell when I import tensorflow, there is no error
In 3.9 python shell when I import tensorflow there is error
when I run pip --version command it gives me this warning
pip --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 22.0.4 from C:\Users\prana\AppData\Roaming\Python\Python37\site-packages\pip (python 3.7)
I don't know what is causing streamlit to not found tensorflow module, please help me.

ImportError: No module named 'pip._vendor.requests' for python3

Have installed pip3 via sudo apt-get. But while trying to check the pip3 --version, its throwing
ImportError: No module named 'pip._vendor.requests'
How do i fix this?
server -- Linux Debian 4.9.65-3,
Python version -- Python 3.5.3
p.s. have tried uninstalling and reinstalling pip3 but no luck.
Full stack trace:-
Traceback (most recent call last): File "/usr/bin/pip3", line 9, in
from pip import main File "/usr/lib/python3/dist-packages/pip/init.py", line 21, in
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning ImportError: No module named 'pip._vendor.requests'

ImportError: cannot import name RemovedInDjango19Warning

I'm on Django 1.8.7 and I've just installed Django-Allauth by cloning the repo and running pip install in the app's directory in my webapp on the terminal. Now when I run manage.py migrate, I get this error:
➜src git:(master) ✗ python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 10, in <module>
from django.apps import apps
File "/Library/Python/2.7/site-packages/django/apps/__init__.py", line 1, in <module>
from .config import AppConfig
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 6, in <module>
from django.utils.module_loading import module_has_submodule
File "/Library/Python/2.7/site-packages/django/utils/module_loading.py", line 4, in <module>
from importlib import import_module
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 6, in <module>
from django.utils.deprecation import RemovedInDjango19Warning
ImportError: cannot import name RemovedInDjango19Warning
➜ src git:(master) ✗
I've checked and I'm still on django 1.8.7 so it wasn't accidently upgraded.
#MaxRah This is caused by conflicts in Django versions. As mentioned by others, you will have to remove pip uninstall django and reinstall your preferred version: pip install django==1.9 This should resolve the issue.
I was getting this error while trying to use cron-jobs on python (using kronos library)
#getting error while trying to run kronos cron job
python manage.py runtask complain
as # olivrg metioned this fixed the issue (reinstall django in my case i was using version 1.8.X so i upgraded to 1.9X)
sudo pip uninstall django
sudo pip install django==1.9
Your installation is corrupt, your traceback does not match the code from version 1.8.7 (from importlib import import_module is on line 8, not line 4). You need to uninstall Django and do a clean install.
I would highly recommend to set up a virtual environment for your Django project, using virtualenv. This is a de facto standard to separate different python environments on your system. The corruption likely occurred because different projects tried to install different versions of Django in your system-wide site packages.
pip install -Ur requirements.txt
Use This Command It Will Work

How to use Python 3 (3.5) as the default interpreter in my virtual environment?

I ran into problems when I installed Python 3.5 on Mac. I wanted to use Python 3.5 as the interpreter when I ran my Django development server. I got this issue when I tried it (I know I must install a virtualenv, read below):
$ python3 manage.py runserver
Traceback (most recent call last):
File "manage.py", line 7, in <module>
from mezzanine.utils.conf import real_project_name
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Mezzanine-4.0.1-py3.5.egg/mezzanine/utils/conf.py", line 7, in <module>
from django.conf import global_settings as defaults
ImportError: No module named 'django'
The first was when I tried installing pip packages it installed by default on the Python 2.7 in my virtual environment:
pip install django==1.9rc2
Collecting django==1.9rc2
Downloading Django-1.9rc2-py2.py3-none-any.whl (6.4MB)
100% |████████████████████████████████| 6.4MB 66kB/s
Installing collected packages: django
Successfully installed django-1.9rc2
I use Django so I tried also install a virtual environment for the first time. First I tried it with pip, but that didn't work.
So how do I setup so that my Python3.5 is the default usage when using Python interpreter and in my virtual environment? I can't figure this out or I have done something wrong in my process.
Edit:
Thanks for the answer and comment. I tried with the both solutions and the same error persisted. See output below:
$ virtualenv -p /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 Django/
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 14, in <module>
import shutil
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 10, in <module>
import fnmatch
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fnmatch.py", line 15, in <module>
import functools
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/functools.py", line 21, in <module>
from collections import namedtuple
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 16, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/Library/Python/2.7/site-packages/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
My virtualenv version: 13.1.2
Your error is related to a known virtualenv bug regarding python-future and mixing up the 2.7 and 3.x module paths, the solution is to downgrade virtualenv to a version < 12.04, 12.0.2 is suggested in the link.
Firstly, If you are going to use multiple versions of python,then you must use Virtual Env.Also then Create your virtualenv using the following command so that it uses python 3.5 as default environment :
virtualenv -p python3 envname
and then install django in the virtualenv.after activating your virtualenv

Having trouble installing buildslave on Windows 7

I finally got pip install buildbot-slave to work on Win7 (thanks to another answer on this site), and now when I attempt to create a build slave via:
buildslave create-slave slavefolder blah.blah.com:9989 buildslave password
It kicks back the following error:
Traceback (most recent call last):
File "C:\Python27\Scripts\buildslave", line 3, in <module>
from buildslave.scripts import runner
File "C:\Python27\lib\site-packages\buildslave\scripts\runner.py", line 22, in <module>
from twisted.python import reflect
File "C:\Python27\lib\site-packages\twisted\__init__.py", line 53, in <module>
_checkRequirements()
File "C:\Python27\lib\site-packages\twisted\__init__.py", line 37, in _checkRequirements
raise ImportError(required + ": no module named zope.interface.")
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.
I've got it all installed here is my pip freeze:
Twisted==14.0.0
argparse==1.2.1
buildbot-slave==0.8.9
stevedore==0.15
virtualenv==1.9.1
virtualenv-clone==0.2.5
virtualenvwrapper==4.3.1
virtualenvwrapper-win==1.1.5
zope.interface==4.1.1
Any recommendations would be greatly appreciated.
Try to uninstall zope.interface and reinstall the version 3.6.0 using the command
pip uninstall zope.interface
pip install zope.interface==3.6.0
Hope this helps.

Categories

Resources