Python Forum
ImportError: cannot import name 'get_config'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError: cannot import name 'get_config'
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Cannot import easysnmp: ImportError: libnetsnmp.so.30 Calab 4 1,058 Jun-08-2023, 08:52 PM
Last Post: Gribouillis
  ImportError: cannot import name 'Pyfhel' from 'Pyfhel' Anldra12 9 3,573 Dec-13-2021, 06:55 PM
Last Post: Anldra12
  ImportError: cannot import name 'Union' from '_ctypes' (unknown location) ciuffoly 15 10,442 Oct-09-2020, 06:58 AM
Last Post: ciuffoly
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 3,945 Jun-18-2020, 08:07 AM
Last Post: buran
  ImportError: cannot import name 'MidiEvaluator' from 'parser' (Windows 10) spiffspaceman 4 2,696 May-22-2020, 10:16 PM
Last Post: snippsat
  ImportError: cannot import name 'X ' from ' Y' (Unknown location) Arjunpi 1 4,367 Apr-30-2020, 12:56 AM
Last Post: Larz60+
  problem with mapnik in anaconda python 2: from _mapnik import * ImportError: DLL load parsley 0 1,911 Dec-11-2019, 07:50 AM
Last Post: parsley
  getting ImportError: cannot import name 'HAProxyServer' deepakkr3110 0 1,650 Nov-12-2019, 07:48 AM
Last Post: deepakkr3110
  ImportError: cannot import name 'gui' from 'appJar' CabbageMan 1 2,824 Sep-04-2019, 07:31 PM
Last Post: Gribouillis
  ImportError: cannot import name 'path' user123 2 12,471 Jul-14-2019, 10:08 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020