-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to import tensorflow in jupyter (yet able to import tensorflow in python and ipython) #2120
Comments
Did you install tensorflow from source? Are you running jupyter from the ts source directory? |
Hi. That seems to be a generic error message, as I installed tf from source and I am not running from its source directory. Now the problem must be that jupyter is unable to find "@rpath/libcudart.8.0.dylib" which is part of the cuda runtime (Strangely enough both python and ipython is able to find it). |
Try running the following in both the notebook and ipython: import sys
sys.executable Odds are they are using different python executables. If this is the case, you can update your python kernelspec. See #397 for reference. |
I tried that, and they are both using '/usr/local/opt/python/bin/python2.7' (which I think should be the homebrew python). |
I'd guess it's something to do with environment variables, but I don't know which. You may be better off asking in a tensorflow forum what might cause the error that you see. |
@takluyver It's a bit strange, because the tensorflow installation runs fine in my python and ipython. So it shall have something to do with the way jupyter calls the tensorflow installation. (On the other hand, jupyter is able to import tensorflow on my Windows PC...) |
Right, but Jupyter just runs your code; it doesn't do anything specific to tensorflow. This might be a job for envzigzag. Try installing that, then run |
@takluyver Thanks. As I am running python 2.7 I couldn't run it. However, I imported os and checked os.environ, and I found I have 'DYLD_LIBRARY_PATH' in my python os.environ, but not in my Jupyter console os.environ. So this must be the cause. But I am not sure how to solve it. |
Are you launching the Jupyter applications from a GUI launcher? If so, they won't pick up environment variables set in On Linux, you can set environment variables in |
@takluyver I am running from console and I have change .bashrc and .bash_profile etc... It seems other people ran into similar problems before. I tried the method in #1290 (by ZlodeiBaal) and it works now. |
Glad you've got it working. I'm a bit confused about what the problem was, but my suspicion is that there's nothing we can do in Jupyter to fix it. |
@gnestor Could you please explain how to update python kernelspec. Note : As you have mentioned in previous post I have different python executables. |
Ok, to find the location of your kernelspecs: Then, edit your |
@gnestor HI, I have similar problem and can not solve it. Can you explain how to |
@rylanchiu First, run
To edit the spec for
Lastly, we want to open
|
@gnestor Thanks for your detailed and helpful instruction! It solved my problem perfectly! |
I do have the same problem as OP, and I wonder what could be done without modifying the notebook config manually? I have en environment variable LD_LIBRARY_PATH, which is not picked up by jupyter. python3 picks it up just fine, but when launched from jupyter it's gone. They both use the same executable (/usr/bin/python3). I launch jupyter from the terminal, same as python3. |
How are you launching the notebook? If you're using some kind of GUI launcher, try launching it from the terminal with |
I am launching from terminal, with the command |
Is LD_LIBRARY_PATH set in the terminal before you launch? I don't think we do anything to unset it. |
OK, after closing all sessions and trying again I am unable to reproduce. I can confirm that jupyter picks up the environment variables of the calling terminal. Must have had an atypical terminal session somewhere in there. Sorry about that. |
I have tried your way @gnestor, unfortunately, it did not work. So I kept searching and found an answer from StackOverflow (https://stackoverflow.com/questions/37061089/trouble-with-tensorflow-in-jupyter-notebook). After following the steps shown in the answer and changed python executable python, as you recommended, from "/Users/username/anaconda/bin/python" to just "/Users/username/anaconda/envs/virtualproject/bin/python", the jupyter notebook successfully imported tensorflow! |
FWIW on OSX, this helped me: jupyter/jupyter#245 (comment) |
I had a similar issue. It could be that your Jupyter notebook is looking into a different path than where you have installed tensorflow. You want to make sure Jupyter opens the correct Python through the correct kernel.
You can then run Jupyter and when selecting a notebook from the New dropdown menu, make sure you select the Python that is connected to the kernel you want (kernel where you have all the libraries and dependencies such as tensorflow) |
Hi guys, IOError: [Errno socket error] [Errno -3] Temporary failure in name resolution |
@Kanagachidambaresan Have you read/tried @Giccuk's solution? https://stackoverflow.com/questions/37061089/trouble-with-tensorflow-in-jupyter-notebook |
I solved the problem by adding |
I am on Windows 10 and using Tensorflow (tf) 1.13. Here is how I resolved it.
Summary: |
Yes! that worked thanks |
I have been trying to fix this problem for days, but still failing. Can anybody enlighten me what else I need to do? My python environment is:
What I have tried:
However, I'm still getting this:
If I try
Both Can anybody help me this issue??? I figured it out myself. I'm leaving the way how it got fixed, so someone might need to try this. |
I had the same problem, as I was inside my conda environment. The jupyter wasn't using the respective python path. I followed some of the advices here and respective links. I present my solution. By following this guideline: If you want to have multiple IPython kernels for different virtualenvs or conda environments, you will need to specify unique names for the kernelspecs. Make sure you have ipykernel installed in your environment. For example, using conda environments, install a Python (myenv) Kernel in a first environment:
After this, restart/launch jupyter, open any notebook, and under the 'Kernel' tab you can specify in 'Change kernel' your newly created kernel. Hope this helps, because it solved my issue |
I am using OSX 10.11 with homebrew python, and tensorflow GPU with cuda and cudnn installed.
Currently tensorflow imports correctly in both python and ipython:
Yet I am unable to import tensorflow in jupyter (I have tried both Jupyter notebook and Jupyter console):
I have tried adding the following in ~/.bashrc and ~/.bash_profile and /etc/profile , yet it still does not work......
export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH="$CUDA_HOME/lib:$DYLD_LIBRARY_PATH"
export PATH="$CUDA_HOME/bin:$PATH"
The text was updated successfully, but these errors were encountered: