Python Forum

Full Version: ImportError: cannot import name 'get_config'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working through some backend testing.

My problem is I cannot identify the right combination of libraries that work. I am using a machine learning algorithm running inside docker container.

This is what is inside the container:
# Install all of the packages
RUN wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py
RUN pip install numpy
RUN pip install scipy
RUN pip install scikit-learn
RUN pip install pandas
RUN pip install flask
RUN pip install gevent
RUN pip install gunicorn
RUN pip install tensorflow==2.2.0
RUN pip install keras
RUN pip install backtrader
RUN pip install matplotlib==3.2.2
RUN pip install ta-lib
RUN pip install boto3
The container is using tensorflow version 2.2.0. The container is pulling the latest for keras. When the Python script is imported I get the following error:

Error:
Traceback (most recent call last): File "/opt/program/train", line 16, in <module> cls = getattr(importlib.import_module(algo_name), 'MyStrategy') File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/opt/program/algo_ml_long_short_predict.py", line 7, in <module> import keras File "/usr/local/lib/python3.6/dist-packages/keras/__init__.py", line 25, in <module> from keras import models File "/usr/local/lib/python3.6/dist-packages/keras/models.py", line 19, in <module> from keras import backend File "/usr/local/lib/python3.6/dist-packages/keras/backend.py", line 36, in <module> from tensorflow.python.eager.context import get_config ImportError: cannot import name 'get_config'
The import statments are as follows:

import backtrader as bt
from algo_base import *
import math
import numpy as np
import pandas as pd
import tensorflow as tf
import keras
import keras.backend as K
from keras.models import load_model
What I have done is search StackOverflow for answers but those did not work.

Any suggestions would be greatly appreciated.

Thank you in advance.

Russ