handwriting-synthesis icon indicating copy to clipboard operation
handwriting-synthesis copied to clipboard

ModuleNotFoundError: No module named 'tensorflow.contrib'

Open javid235 opened this issue 1 year ago • 4 comments

line 9, in from rnn import rnn line 9, in from rnn_cell import LSTMAttentionCell line 4, in import tensorflow.contrib.distributions as tfd ModuleNotFoundError: No module named 'tensorflow.contrib'

please help me with this problem.

javid235 avatar Sep 07 '23 07:09 javid235

same issue

AceBeaker2 avatar Sep 07 '23 20:09 AceBeaker2

I had the same issue. The code is specifically trying to use Tensorflow 1.6.0 which will only work on Pyhon3.6. Here's what worked for me:

  • install microconda (Python package/env manager)
  • create a new env with python=3.6
  • pip3 install the dependencies and make sure you pip3 install tensorflow=1.6.0 (other dependencies did not need specific version for me)

(I think you can also set up unique python3 envs using pypi envs but I've not tried) image

bmccabe2 avatar Nov 07 '23 05:11 bmccabe2

Hi @javid235 and @javid235 Here's the soloution: -

Step 1: Install Miniconda/Anaconda Download Miniconda/Anaconda from the official website: Follow the installation instructions for your operating system.

Step 2: Create a New Environment with Python 3.6 Open a terminal or command prompt and run the following command to create a new environment named "handwriting-env" with Python 3.6: conda create --name handwriting-env python=3.6

Step 3: Activate the New Environment Activate the newly created environment. On Windows, use: conda activate handwriting-env

Step 4: Install Dependencies Now, navigate to your project directory and run your code: cd path/to/your/project Make sure you are in the activated environment, then install the required dependencies: pip install –r requirements.txt

Step 5: Run the Code python demo.py

Make sure you're using the correct paths in the commands above. Adjust them based on your actual project structure. These steps create a Conda environment, activate it, install the necessary dependencies, and run your code in a version-controlled environment. If you encounter any issues or have further questions, feel free to ask!

GHUFRAN-HYDER avatar Nov 20 '23 07:11 GHUFRAN-HYDER

It's because tensoflow.contrib does not exist anymore in tensorflow 2.0, and as bmccabe2 said, this code is written for tensorflow 1.6. Tensorflow 1.6 is not available anymore on python version > 3.6, this is why you need to use python 3.6. If you use a newer version, you'll install tensorflow >2.0, and then you'll get this error

Fardenco avatar Nov 29 '23 15:11 Fardenco