简体   繁体   中英

tensorflow : ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package

When I try to run

import tensorflow as tf

at pycharm, then I got the error message

ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package

I refer to questions like question 1 and question 2 , they are just to recommend downgrade or reinstalling.

The particularity of this problem is

  1. cmd image When I run import tensorflow in cmd,it works well.
  2. The code of this project is correct because I 'have run it on other computer.And I use CONDA to keep the environment consistent.

I have checked the interpreter of pycharm and this project and it was correct.

How can I resolve it? I have fight with this problems for 3 days.

I had the same problem with you. I found it is the pycharm to be blamed. In tensorflow version later than 2.0.0, the main functions of tensorflow is located in tensorflow_core instead of the folder tensorflow like tensorflow 1.x. When you use cmd, python can find these packages(by some methods), but the pycharm of old version cannot. So update your pycharm or use earlier versions of tensorflow might solve your problem. Unable to import Keras(from TensorFlow 2.0) in PyCharm . these question said that PyCharm can recognises tensorflow 2.0.0b1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM