0

I used this code to import in VSCODE editor.
Getting error as below.
Already installed tensorflow by pip install tensorflow in command line.
Any help please?

import tensorflow  

File "C:\Users\david\python3_6\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
AttributeError: module 'imp' has no attribute 'find_module'
8
  • how did you install tensorflow. Did you build it yourself from source? Commented Jan 20, 2019 at 17:13
  • used 'pip install tensorflow' in cmd. Commented Jan 20, 2019 at 17:36
  • do you have any other file named imp.py in your machine Commented Jan 20, 2019 at 17:36
  • changed to imp1.py. still same issue. Commented Jan 20, 2019 at 17:45
  • which file did you change to imp1.py? Are there any other files named imp.py? Commented Jan 20, 2019 at 17:47

2 Answers 2

3

I had such kind of problem, when my working directory contained custom file with the same name ("imp.py"). Perhaps, your project also contains such file :) Just find and open file that throws an error and then Ctrl+click on "imp" module to open it in separate tab to see what's wrong.

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

Comments

0

If you used

pip install tensorflow

It would most likely install packages corresponding to python2

To install for python3 as your directory suggests, use

pip3 install tensorflow

Also checkout this answer here https://stackoverflow.com/a/37674563/5668215

If it still persists, uninstall or purge the present tensorflow installation using pip and reinstall it using pip3

Comments

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.