14

I am using Anaconda 4.3.1 64 Bit on Windows 10 64 Bit. I have successfully installed Tensorflow (CPU) according tothis. The test program runs in thecommand line, but not inPyCharm. The problem is that it works only withactivate tensorflow.

I followed the steps fromPycharm anaconda import tensor flow library issue ("You need to do these following steps:"). It seems now that tensorflow is loaded, but I get a new error:

ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, trygit clean -xdf (removes all files not under version control). Otherwise reinstall numpy.

How can I use TensorFlow in PyCharm? (BTW: Tensorflow works with PyCharm on my Fedora VM.)

Edit:

Can I use TensorFlow with Jupyter? When running "Jupyter (tensorflow)" from the Anaconda menu, a console window opens and immediately closes.

askedMay 19, 2017 at 1:08
user495236's user avatar

4 Answers4

11
+50

When PyCharm is open: if you navigate to preferences: Project: Project Interpreter. You can there either create your own virtualenv (and then manually install the required packages) or make sure you have selected the anaconda python interpreter for your project.

answeredMay 26, 2017 at 7:41
PdevG's user avatar
Sign up to request clarification or add additional context in comments.

5 Comments

Can you elaborate a bit? What settings do I have to use for the creation of my virtualenv? The Anaconda Python interpreter is already selected.
For the virtualenv I would use whatever interpreter you have that works best. This probably is anaconda. Then you give it a name (I mostly choose a name similar to my project). Afterwards in the same menu (Project Interpreter) you see a list of packages you have installed. If you want to install TensorFlow you click on the + in the bottom left and select tensorflow. Press install package and it should work. If you have any missing dependencies you can install them the same way.
As a side note, you should run your files in this virtualenv for this to work. This is done automatically if you run your scripts using pycharm. If you insist on running your scripts from the command line you need to first mount your virtualenv. When you have the virtualenv wrapper installed this is as easy as typing: "workon <virtualenv_name>" afterwards you can run your script.
Thank you. When adding TensorFlow, I get the error "Collecting tensorflow==1.1.0rc2 Could not find a version that satisfies the requirement tensorflow==1.1.0rc2 (from versions: ) No matching distribution found for tensorflow==1.1.0rc2" (The same for the other versions of tensorflow.)
That is superweird. It seems to be an issue with this particular package then.stackoverflow.com/questions/38896424/… seems to offer a few solution. You can try those. Hope you can get it figured out!
5

If followingofficial instructions, you have created a virtual environment calledtensorflow. The environment is located inAnaconda3\envs\tensorflow directory, whereAnaconda3 is the Anaconda installation directory. You just need to point PyCharm to thepython.exe which is located there.

The settings path in PyCharm is something like this:

Settings->Project Interpreter->Add Local->Virtualenv Environment->Existing environment

Point the interpreter to thepython.exe in theAnaconda3\envs\tensorflow directory.

answeredDec 9, 2017 at 22:32
klimkin's user avatar

Comments

3

I recommend installingbabun and creating avirtualenv withvirtualenvwrapper there and install on that environment.

After doing this, just choose thepython binary in the relevant directory of the virtualenv you created, i.e.~/.virtualenvs/myenv/bin/python or~/.virtaulenvs/myenv/usr/bin/python

answeredMay 26, 2017 at 6:53
onur güngör's user avatar

2 Comments

How do I create avirtualenv withvirtualenvwrapper? What shall I install on this environment?
2

Before importing anything else, do this

import sysprint(sys.path)import osprint(os.environ)print(os.environ['CUDA_VISIBLE_DEVICES'])

from the command line (when TF works) and from PyCharm (when it doesn't). If you see any relevant differences, adjust accordingly (define the environment variables in PyCharm, etc.)

answeredMay 24, 2017 at 3:55
MWB's user avatar

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy 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.