1

I'm working on PyCharm 2018.1. I've already created an environment and successfully installed tensorflow through conda, but the Python interpreter still can't find the package. That's the error I get:

Traceback (most recent call last):
File "/home/federico/PycharmProjects/HandGestureRecognition/demo.py", line 3, in <module>
import tensorflow as tf
ImportError: No module named tensorflow

I'm sure I've installed tensorflow because I can run tensorflow programs from the shell.

Federico Màlato
  • 115
  • 3
  • 14

2 Answers2

1

You have to setup the environment to where you have python installed or setup a virtual environment.

Mine happens to be located in ~/anaconda3/bin/python on my linux and ~/local_interp/bin/python on my mac. If you use the command line you can search for the path where you installed python. If you downloaded using pip install or conda install it should lead you where you need to be.

You can go to "Preferences" --> "Project Interpreter". Choose the tool button at the right top corner.

Then choose "More..." --> "Show path for the selected interpreter" --> "Add". Then you can add a path.

Check out this page. It doesn't have the exact answer you are looking for but it contains all of the information that you would need to figure it out for your particular case. How do I import modules in pycharm?

10donovanr
  • 93
  • 12
1

If you have changed the interpreter and are running the code in Interactive mode; then just close the python console tab and open a new one. That should do the trick. Somehow I think Python console doesn't reference to the new python interpreter even if you change the Project interpreter.

aseem bhartiya
  • 94
  • 1
  • 10