0

I have been running in circles trying to get tensorflow to work in a jupyter notebook. I installed it via pip on ubuntu and also tried a conda environment (but unless I'm mistaken, getting that to work with ipython is beyond my ability). Tensorflow works fine in python3.4, but not python 3.5, which is used when I load ipython. I'm not sure if this question makes any sense, but can I make it so that ipython uses only python 3.4? The reason I need to use ipython instead of going through the python shell is that I am trying to use the kadenzie tutorial.

Thank you.

Edit: I'm not sure how applicable this is to other people with my problem, but I solved it by changing my conda python version (conda install python=3.4.3), uninstalling ipython, and then reinstalling it.

Bowtie
  • 121
  • 1
  • 4
  • Minor note: jupyter or ipython? It's either-or. Have you googled along the lines of "make ipython use older version of python"? Although the proper solution would probably be to have tensorflow installed for your primary python version, or the whole thing in a virtualenv. – Andras Deak -- Слава Україні Dec 19 '16 at 18:43
  • I actually do not know the difference. When load ipython or jupyter notebook, it leads me to the same jupyter page. I have googled this, and got [this stack](http://stackoverflow.com/questions/30492623/using-both-python-2-x-and-python-3-x-in-ipython-notebook/34464003#34464003), but I don't care about having multiple environments -- I just want the main one to use 3.4 – Bowtie Dec 19 '16 at 18:48
  • There are top google hits [such as this one](http://stackoverflow.com/questions/9386048/ipython-reads-wrong-python-version?noredirect=1&lq=1). And jupyter is a spin-off from ipython; although you're right in that there is only one kind of *notebook*: formerly ipython-notebook, now jupyter-notebook:) I suggest that you call it jupyter-notebook (as opposed to ipython, without the notebook). Sorry for the confusion. – Andras Deak -- Слава Україні Dec 19 '16 at 18:52
  • No problem, and I hope you can help me fuddle through that link you gave me --- "which python"/ipython leads me to usr/anaconda3/bin, not usr/bin. Does that change the procedure? – Bowtie Dec 19 '16 at 18:55
  • Note that the answer given there is not the best practice, it's (as noted) a "quick fix". Anyway: the point of `which` is to locate the path to your python executable. You need to get the path of `python3.4` using `which`, if this is what you want ipython to use. Then you need to edit ipython's executable to make it contain the right [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)), so that running ipython invokes the older interpreter. – Andras Deak -- Слава Україні Dec 19 '16 at 18:58
  • Note that Anaconda already comes with Ipython. Installing tensorflow in Anaconda is as easy as `conda install tensorflow`. – jmd_dk Dec 19 '16 at 19:28
  • 1
    Well, I deleted a bunch of stuff, downgraded my default python version in anaconda, destroyed ipython entirely, and reinstalled it. And now everything works, somehow. Thank you, I am going to go take a shower. – Bowtie Dec 19 '16 at 19:30

2 Answers2

0

Each major version of python has its own site-packages directory. It seems that you have both python 3.4 and 3.5 and you have jupyter installed in 3.5 and tensorflow in 3.4. The easy solution is to install tensorflow in 3.5 as well. This should allow you to use it with the 3.5 notebook kernel. You could attempt to add 3.4 as a kernel, but I am not sure how to do that.

Mad Wombat
  • 14,490
  • 14
  • 73
  • 109
0

The best way to setup tensorflow with jupyter 1.Install anaconda 2.Create a environment named "tensorflow" 3.activate that environment by the following command in command prompt

  • Install anaconda
  • Create a environment named "Tensorflow"
  • activate that environment by the following command in command prompt

    activate tensorflow

  • then type conda install ipykernel

  • then when it is installed paste the following command

    python -m ipykernel install --user --name myenv --display-name "Python[Tensorflow]"

Then run jupyter notebook in command prompt

after that when you are going to create a new notebook you will see two types of notebook just select the tensorflow one.