0

I am working on my laptop with tensorflow 2.4.1 and keras 2.3.1 in an anaconda virtual environment. Unfortunately I need to run my code on a remote machine, but I am having tons of problems in setting up a working virtual environment there. I even tried to export my working venv on my laptop there via a myenv.yml file without success. When I try to import keras in my code using myenv on my virtual machine I run into the error 'ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context', that I do not get on my laptop with the same venv.

I know I can use from tensorflow import keras (I have already tried and it worked) but my problem is that I need to import hyperas (specifically, I need to 'from hyperas import optim' ) and this line keeps throwing the same 'ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context' error.

I have tried upgrading tensorflow via conda install -c conda-forge tensorflow , but it doesn't solve the environment. I have tried creating new environments and manually installing keras, tensorflow etc but I keep running in the same problem.

What can I do?

Vale
  • 1
  • are you using a python venv or a conda env? – Alberto Sinigaglia Jul 25 '22 at 13:44
  • I am using conda env, specifically, I transformed the conda env in my laptop in a yml file, copied it to the remote machine and activated it there – Vale Jul 27 '22 at 13:57
  • And with that yml using `conda env create` it works just fine on your laptop? also consider that some versions are available only to some envs, ie TF has some versions that are supported by everyone, others that M1 Mac can't have and so on – Alberto Sinigaglia Jul 27 '22 at 15:04

1 Answers1

0

I am able to successfully import hyperas in the same environment. Please ensure that you have the same versions of TensorFlow and keras installed in your virtual environment and then try running your code again by installing the hyperas package.

Please check the screen shot below: enter image description here