Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'tensorflow.contrib' #73

Open
javid235 opened this issue Sep 7, 2023 · 4 comments
Open

ModuleNotFoundError: No module named 'tensorflow.contrib' #73

javid235 opened this issue Sep 7, 2023 · 4 comments

Comments

@javid235
Copy link

javid235 commented Sep 7, 2023

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.

@AceBeaker2
Copy link

same issue

@bmccabe2
Copy link

bmccabe2 commented Nov 7, 2023

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

@GHUFRAN-HYDER
Copy link

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!

@Fardenco
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants