0

I am working on a project where I have to use TensorFlow and Keras modules on my Windows10 machine. I first created my virtual env using anaconda prompt

$ conda create -n tensor-env
$ conda activate tensor-env

After this, I have installed some python libraries that I need to use.

When I do $conda list I can see that TensorFlow is installed (see image).

But after this and when I try to use it on my .py files I get an error message saying that it can't find the module (see image).

Am I missing something here? I've tried many tutorials so far and I can't see how to fix this problem, am I missing CPU TensorFlow installation or something?

Thank you everyone for reading it :)

3
  • May you please show the output of conda show tensorflow Commented Aug 16, 2021 at 15:47
  • 1
    stackoverflow.com/questions/46568913 Commented Aug 16, 2021 at 15:48
  • I cant do that comand, it says: No command 'conda show'. But when i do ` conda list` i can see tensorflow=2.3.0 But i have solved this issue now, i belive the problem was that i was using Python=3.9 and isnt supported for tensorflow, so i downgraded to Python=3.8 and apparently i have no import errors once again. But now i am facing a new error in this line of code loss = keras.losses.SparseCategorialCrossentropy(from_logits=True) saying that module 'tensorflow.keras.losses' has no attribute 'SparseCategoricalCrossentropy'. Any ideia how to solve it? i already had this error weeks ago Commented Aug 16, 2021 at 16:02

1 Answer 1

0

After creating virtual environment , you again need to install tensorflow and keras into that environment to run your program.

You can run below commands in anaconda prompt.

conda create -n tensor-env

conda activate tensor-env

conda install tensorflow

conda install keras

Now select this environment in anaconda navigator and open the jupyter notebook in same environment to run the program. Please let me know if this resolve your program error.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much, it sure did solve my problem! I was having some issue with anaconda, that when i restarted my laptop all my installed modules were gone from the env. But its all fine now, i mannaged to solve it, thank you very much for your time and effort to reply.
Great that I could help you, Please mark if this answer was useful. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.