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 :)

Xbel
  • 735
  • 1
  • 10
  • 30
Nuno Cruzes
  • 3
  • 1
  • 5
  • May you please show the output of `conda show tensorflow` – dio Aug 16 '21 at 15:47
  • 1
    https://stackoverflow.com/questions/46568913/ – dio Aug 16 '21 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 – Nuno Cruzes Aug 16 '21 at 16:02

1 Answers1

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.

Haha
  • 973
  • 16
  • 43
Renu Patel
  • 51
  • 2
  • 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. – Nuno Cruzes Aug 26 '21 at 18:54
  • Great that I could help you, Please mark if this answer was useful. Thanks! – Renu Patel Aug 27 '21 at 06:52