-
Notifications
You must be signed in to change notification settings - Fork 74.7k
Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory #1402
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
Comments
You should start your python outside tensorflow directory. Because python will import tensorflow from current directory. |
I had the same errors as you did. I solved this by reinstall protobuf, by |
Yes. I built from source, but I didn't do anything special for bazel. I pip install wheel --no-deps -U Sent from a mobile device
|
@raingo did you do git clone --recurse-submodules https://github.com/tensorflow/tensorflow or clone without the submodules since you are installing protobuf separately |
Uninstall protobuf before building (or dl whl), everything works fine after that. Had the same issue. sudo pip uninstall protobuf |
@Dringite do you mean uninstall protobuf, build from the .whl and then install protobuf the way @raingo mentioned? |
Problem solved @Dringite you were right, there was no need to have protobuf installed at all. The steps are
Notice that i added --define=use_fast_cpp_protos=true in the build command so it might have actually helped. |
@ushnish I have followed your way to install tensorflow-0.7.1. In the future if I want to upgrade the version of tensorflow, is it necessary for me to follow your way to install new version? Or is there any other convenient ways? |
Tensorflow 0.9.0 also suffers from the same issue. The answer from @Dringite can solve the issue. (i.e., pip uninstall protobuf and tensorflow, then pip install tensorflow) |
Tensorflow 0.10.0 also suffers from the same issue. The answer from @raingo can solve the issue. (i.e. |
According to the above method Still not solve `Python 2.7.3 (default, Jun 22 2015, 19:33:41)
Error importing tensorflow. Unless you are using bazel, |
I'm running Ubuntu 14.04.5 LTS with A quick hack to get you by:
and replace |
I got a similar error. It was solved when I run python from the parent directory of tensorflow. But I'm curious if I can import tensorflow from another directory? Because when I do, it shows this error. |
Looks like it is related to this line when running tensorflow from source dir, https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/__init__.py#L49 This should be resolved by not running from the source dir. |
Thank you all, I solved the problem by upgrading the ubuntu |
@martinwicke @yifeif I used pip installation. To be exact, I used these three commands: $ sudo easy_install pip #the CPU version of the binaries to Pypi |
@martinwicke I just |
@baregawi #4616 is different, we are removing spurious symbols from our packages, so a lot of these direct imports will stop working. This issue is different, and in the past, this has pointed to tensorflow now being properly installed. It's hard to debug remotely though. @ushnish how many pythons do you have installed and which one is tensorflow installed in? Can you install tensorflow in a virtualenv? If that works, then there's some problem with conflicting versions, either python/ipython or more than one tensorflow installation. |
@martinwicke I installed tensorflow_gpu-0.12rc1-py2-none-any.whl step by step via the instruction of official site. execute this command:
But unfortunately, I got the same error as following output:
The version of mac system: Thank u 4 any response. |
@R0rs12ach: Are you installing this on PPC? If so, you'll have to install from source, our binary packages only support x86_64. |
@R0rs12ach: i had the same problem using mac OS X Yosemite. So far i have tried:
and as said, instead of install with pip i have made it with Anaconda installation from trensorflow homepage: https://www.tensorflow.org/get_started/os_setup#anaconda_installation Hope it will help you. |
@martinwicke I think my computer's arch is :
the fact is that my computer just x86_64 @MeilingShi : Thank u 4 ur advice, I will try it and paste the result |
@MeilingShi I have tried what you said above, but nothing change. In fact, the cuda sdk do not support intel graphic 4000. So, i give up to install tensorflow_gpu_version on my mac which bought at 2013. |
@R0rs12ach yes, CUDA only works with NVIDIA graphics cards. It's still confusing me that it would complain about the library architecture. Others, I would like to understand this issue, but this thread has become too noisy. Whoever still has this problem, can you open a new issue with your system config according to the template? |
@rodrigomfw can you paste the error before that message? For some people on this thread it's that they have very old systems (CentOS 6.x) which don't support the pre-built binaries. For you it's probably something else since it only affects GPU. @vrv, I think we should rephrase this error. Most of the time (100% of the time in this thread), this is a failure to import unrelated to the working directory. |
Yup, something changed and we now raise ImportError much more often, so the error message is unhelpful. |
I just uninstalled tensorflow and tensorflow-gpu both and then I just installed tensorflow-gpu... works perfectly fine for me |
Facing this error when installing tensorflow on windows 8 with python 3.5 and importing it from IDLE. I think it is the same issue.
During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Error importing tensorflow. Unless you are using bazel, |
I did everything above but I always get this:
|
I got over the problem by reinstalling cuda 8.0 and cudnn 5.1 |
Maybe this can help you when you got this "Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory" #559 |
I am also facing the same issues, wondered if anyone has resolved it? But my error is slightly different ImportError: numpy.core.multiarray failed to import But i have tried all the solutions mentioned above, and still facing that problem "Error importing tensorflow." |
try this one |
If anyone had the same problem as mine, i managed to fix it. My error was Because i am running on a Mac, there are 2 sets of numpy thats running at the same time, as the Mac came with Python installed, so even if you are updating the numpy, it wasnt updating the one thats needed for Tensorflow. I believe i ran sudo pip install numpy -U --upgrade or something like that so all versions of numpy would be upgraded within my Mac. Then it worked after that. |
What does it mean to be in the "source directory". I am also having the same issue however, I have no idea what the source directory is. |
seems no solution yet. I am installing gpu version on windows 10. The installation seems ok at least no error or warning. pip install --ignore-installed --upgrade C:\Users\dbsnail\Downloads\tensorflow_gpu-1.0.0rc2-cp35-cp35m-win_amd64.whl
During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Failed to load the native TensorFlow runtime. |
I got the solution, install cuDNN v5.1 for CUDA 8.0 Then , you should be able to load tensorflow without any error NOTE, I use python 3.5 |
I first installed wheel, then the tensorflow was installed on my machine(using windows 10). Now, it is not getting imported here is the error : Using TensorFlow backend. During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Error importing tensorflow. Unless you are using bazel, Does any know how to fix it?? |
Guys its simple, |
https://github.com/ravivalluri/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import-error |
I am new to TensorFlow and I am facing the same issue. Kindly suggest me to get started with this journey as soon as possible. Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Error importing tensorflow. Unless you are using bazel, |
Hi, I got the same issue:
I do not know where or what is tensorflow source tree, or where is tensorflow source directory. I just followed the instructions here - https://www.tensorflow.org/install/install_windows and now trying to follow this - https://www.tensorflow.org/get_started/get_started This was exactly after following the getting started guide and trying a import tensorflow as tf. Please help!! |
Hi Abhishek,
I am still not resolved with this issue if you find potential fixes than
please let me know.
…On Sep 12, 2017 1:50 PM, "Abhishek" ***@***.***> wrote:
Hi, I got the same issue:
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
This was exactly after following the getting started guide and trying a
import tensorflow as tf.
Wondering why is this issue closed when so many people still have the
issue.
I couldn't find the solution anywhere on this thread or on stackoverflow.
Please help!!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1402 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANfiFJR4BmqpKC3Uogd0IgvwdIfrMYv2ks5shj7YgaJpZM4HqPp5>
.
|
Oh,my solution is upgrading the pip to latest version, then use it to reinstall tensorflow |
lol, you guys are just naive! It's clearly written that you cant import tensorflow on the terminal itself, C'mon go and create a python file and then compile it silly! |
This thread seems somewhat old, but just to share the problem I had and how I solved it. I first tried to import keras, but I faced the same error on this issue title. I uninstalled protobuf and updated tensorflow. It worked.
|
…gfx90a Permanently enabling sramecc for gfx90a
These are the sequence of steps i followed to install the distributed version of TF
Now for the error
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
Can someone help me understand what might cause this? Thank you.
The text was updated successfully, but these errors were encountered: