Python Forum
Cryptic Error with import statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cryptic Error with import statement
#1
In the following import statements there is an error

from utils.create_features_utils import *
import pandas as pd
import numpy as np
from keras import models, layers
from keras.callbacks import ModelCheckpoint, EarlyStopping
from keras.preprocessing.text import Tokenizer
It apparently does not like the statement

from keras import models, layers
It gives a very cryptic error. Which I do not understand. By the way keras is installed.

this is the error that I get on that initial line.


Error:
AttributeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_21752/4287243873.py in <module> 2 import pandas as pd 3 import numpy as np ----> 4 from keras import models, layers 5 from keras.callbacks import ModelCheckpoint, EarlyStopping 6 from keras.preprocessing.text import Tokenizer ~\miniconda3\lib\site-packages\keras\__init__.py in <module> 19 """ 20 # pylint: disable=unused-import ---> 21 from tensorflow.python import tf2 22 from keras import distribute 23 ~\miniconda3\lib\site-packages\tensorflow\__init__.py in <module> 39 import sys as _sys 40 ---> 41 from tensorflow.python.tools import module_util as _module_util 42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader 43 ~\miniconda3\lib\site-packages\tensorflow\python\__init__.py in <module> 45 from tensorflow.python import data 46 from tensorflow.python import distribute ---> 47 from tensorflow.python import keras 48 from tensorflow.python.feature_column import feature_column_lib as feature_column 49 from tensorflow.python.layers import layers ~\miniconda3\lib\site-packages\tensorflow\python\keras\__init__.py in <module> 25 26 # See b/110718070#comment18 for more details about this import. ---> 27 from tensorflow.python.keras import models 28 29 from tensorflow.python.keras.engine.input_layer import Input ~\miniconda3\lib\site-packages\tensorflow\python\keras\models.py in <module> 24 from tensorflow.python.keras import metrics as metrics_module 25 from tensorflow.python.keras import optimizers ---> 26 from tensorflow.python.keras.engine import functional 27 from tensorflow.python.keras.engine import sequential 28 from tensorflow.python.keras.engine import training ~\miniconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py in <module> 36 from tensorflow.python.keras.engine import keras_tensor 37 from tensorflow.python.keras.engine import node as node_module ---> 38 from tensorflow.python.keras.engine import training as training_lib 39 from tensorflow.python.keras.engine import training_utils 40 from tensorflow.python.keras.saving.saved_model import network_serialization ~\miniconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in <module> 51 from tensorflow.python.keras.engine import training_utils 52 from tensorflow.python.keras.mixed_precision.experimental import loss_scale_optimizer as lso ---> 53 from tensorflow.python.keras.saving import hdf5_format 54 from tensorflow.python.keras.saving import save 55 from tensorflow.python.keras.saving.saved_model import model_serialization ~\miniconda3\lib\site-packages\tensorflow\python\keras\saving\hdf5_format.py in <module> 39 # pylint: disable=g-import-not-at-top 40 try: ---> 41 import h5py 42 HDF5_OBJECT_HEADER_LIMIT = 64512 43 except ImportError: ~\miniconda3\lib\site-packages\h5py\__init__.py in <module> 32 raise 33 ---> 34 from . import version 35 36 if version.hdf5_version_tuple != version.hdf5_built_version_tuple: ~\miniconda3\lib\site-packages\h5py\version.py in <module> 15 16 from collections import namedtuple ---> 17 from . import h5 as _h5 18 import sys 19 import numpy h5py\h5.pyx in init h5py.h5() AttributeError: type object 'h5py.h5.H5PYConfig' has no attribute '__reduce_cython__' [code]
I do not understand this error. How do I correct it? As I said before keras 3.0.0 is installed.

Thanks in advance for any help.

Respectfully,

LZ
Reply
#2
check https://github.com/h5py/h5py/issues/1477
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
I will thank you for your speedy reply.

LZ
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 696 Sep-05-2023, 12:50 PM
Last Post: ToniE
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,681 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  import module error tantony 5 3,443 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Error in Using INPUT statement gunwaba 1 2,072 Jul-03-2022, 10:22 PM
Last Post: deanhystad
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,623 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  getting an import statement to work in my program barryjo 1 1,659 Dec-06-2021, 04:28 PM
Last Post: snippsat
  import module with syntax error Skaperen 7 5,278 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  Import Error Christian 3 3,180 Apr-17-2021, 11:27 PM
Last Post: bowlofred
  import statement in a virtual environment leodavinci1990 1 2,350 Mar-04-2021, 12:57 AM
Last Post: snippsat
  Folium import error kashif_flavio 2 3,649 Dec-07-2020, 08:58 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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