I have just installed Anaconda in a Ubuntu 14.04. Then I installed tensorflow using
conda install -c https://conda.anaconda.org/jjhelmus tensorflow
Then I installed protobuf
conda install -c https://conda.anaconda.org/anaconda protobuf
However, I am not able to solve this issue:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/daniel/anaconda2/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "/home/daniel/anaconda2/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)
File "/home/daniel/Documents/Cursos/UnB/Metodos Computacionais/2016/Notas de Aula/Part II - Aula 1 Regression Linear Models/biasVersusVarianceSeveralData.py", line 8, in <module>
import tensorflow as tf
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 69, in <module>
from tensorflow.python.training import training as train
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/training.py", line 149, in <module>
from tensorflow.python.training.saver import generate_checkpoint_state_proto
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 29, in <module>
from google.protobuf.any_pb2 import Any
ImportError: No module named any_pb2
Use the instructions on the TensorFlow site.
TLDR;
I am posting this as an answer because people don't look for answers in the comments.
Here's my comment on the issue from github, hope this helps.
"For anyone else who is running into the same issue, I was also having similar problems when trying to import tensorflow on notebook via jupyter. The modules were installed using conda. After spending two days on it without any success (kept getting the same, no module any_pb2/contrib), it was obvious it was a notebook problem and not tensorflow related since I could import tensorflow from python shell. So I decided to switch back to vanilla python and installed everything manually (tensorflow via pip & got rid of jupyter & installed ipython instead) and now I am able to import tensorflow from my ipython notebook."
Original comment link: https://github.com/tensorflow/tensorflow/issues/1161#issuecomment-188664103
The following worked for me:
conda install -c https://conda.anaconda.org/jjhelmus tensorflow
Related
My VS Code Editor for Python is not able to import transformers even though I have done a conda install and giving me the following error
Traceback (most recent call last):
File "c:/Users/I323017/Documents/Studies/question_answering_kinnal/src/main.py", line 3, in <module>
import transformers
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\__init__.py", line 107, in <module>
from .pipelines import (
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\pipelines.py", line 40, in <module>
from .tokenization_auto import AutoTokenizer
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_auto.py", line 49, in <module>
from .tokenization_flaubert import FlaubertTokenizer
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_flaubert.py", line 23, in <module>
from .tokenization_xlm import XLMTokenizer
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_xlm.py", line 26, in <module>
import sacremoses as sm
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\__init__.py", line 2, in <module>
from sacremoses.tokenize import *
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\tokenize.py", line 10, in <module>
from sacremoses.util import is_cjk
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\util.py", line 11, in <module>
from joblib import Parallel, delayed
ModuleNotFoundError: No module named 'joblib'
May I know the problem here?
The error clearly suggests:
ModuleNotFoundError: No module named 'joblib'
Try pip install joblib
Also make sure you have latest torch and transformers library installed.
This seems to be an installation issue. If you have already installed transformers using conda install -c conda-forge transformers, an additional upgradation from the source using the below resolved my issue.
git clone https://github.com/huggingface/transformers.git
cd transformers
pip install .
As #Vishnukk has stated, this seems like an installation problem.
HuggingFace has now published transformers officially via their own conda channel
Doing conda install transformers -c huggingface should then work after removing the old version of transformers.
I am going mad for installing and import tensorflow for 6 weeks. I did everything; I installed it from spyder, Conda prompt and with different commands like pip install tensorflow and conda install tensorflow. my python version is 3.7 and after install when I want to import tensorflow in spyder I get this message:
import tensorflow
Traceback (most recent call last):
File "<ipython-input-4-d6579f534729>", line 1, in <module>
import tensorflow
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 27, in <module>
from tensorflow._api.v2 import audio
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\_api\v2\audio\__init__.py", line 8, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 9, in <module>
from google.protobuf import symbol_database as _symbol_database
File "C:\Users\sally\Anaconda3\lib\site-packages\google\protobuf\symbol_database.py", line 184, in <module>
_DEFAULT = SymbolDatabase(pool=descriptor_pool.Default())
AttributeError: module 'google.protobuf.descriptor_pool' has no attribute 'Default
This is a very common issue. I have been there.
First: provide the following information:
- what operating system?
- do you want to run on cpu or gpu?
- if gpu, what gpu do you have?
- are your drivers up to date?
- Are your trying to run tensorflow though an IDE like Pycharm, is it more like Jupyter notebook stuff, or just cmd.
Second: There are some link that might be usefull. Here they are.
https://www.tensorflow.org/install/pip
https://www.tensorflow.org/install/gpu#software_requirements
There is a video that helped me, it might help you as well. With tensorflow it is really important to follow the instructions precisely, not missing any steps, and very important, not assuming that installing something with a higher version is no issue. If it says install 'whatever program'.version.1.1.x you can not install 'whatever program'.version.1.1.y
https://www.youtube.com/watch?v=qrkEYf-YDyI&t=1575s
I installed tensorflow with pip3, then validated it with
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
And all works fine in terminal. However, when i try to import tensorflow in Anaconda it throws up an error:
import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-4-64156d691fe5>", line 1, in <module>
import tensorflow as tf
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/Users/Ivan/anaconda3/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/Users/Ivan/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: #rpath/libcublas.8.0.dylib
Referenced from: /Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Reason: image not found
Failed to load the native TensorFlow runtime.
I tried some things which I found on the internet, and this is what I get:
When I'm trying commands like
conda update --all
I get "conda: command not found". In the terminal and in Anaconda prompt too.
But if in the terminal I enter
zsh
conda info
It works
If I change "Applications on..." in Anaconda from root to tensorflow, it doesn't help.
Screenshot that shows "Applications on tensorflow":
I think I wrongly downloaded and installed the GPU version of tensorflow, but I uninstalled tensorflow and reinstalled CPU version.
I'm using OS X Sierra and Anaconda 4.4.10. How should I approach this problem? I have only basic understanding of terminal.
Search for Anaconda Prompt from the Start menu. Right click on it and select Run as Administrator. In the terminal that opens up, type:
conda install tensorflow
This worked for me.
Thanks everyone for your input) Here is how I solved the problem eventually:
These steps brought me to working tensorflow, but I'm not sure if every one of them was critical.
1) I made sure that my zsh profile worked correctly. It seems that it somehow didn't know conda is installed, I solved it with export PATH=~/anaconda3/bin:$PATH
to ~/.zshrc file.
2) I uninstalled wrong versions of tensorflow (with gpu support) and updated everything (Anaconda, python, pip, etc.).
3) Then I created virtual environment following instructions here specifically for Anaconda installation https://www.tensorflow.org/install/install_mac#the_url_of_the_tensorflow_python_package (I created environment exactly for python 3.6, previously I unthinkingly just used python 3.3 from example, my bad).
4) I chose this environment in Spyder - everything works.
I tried download the package and python setup.py develop. However this directly installs GPflow under anaconda. Plus this isn't really working anaconda and gives error
/Users/Chu/anaconda/bin/python /Users/Chu/Documents/dssg/dssg.py
Traceback (most recent call last):
File "/Users/Chu/Documents/dssg/dssg.py", line 4, in <module>
import GPflow
File "/Users/Chu/Documents/GPflow-master/GPflow/__init__.py", line 18, in <module>
from . import (likelihoods, kernels, ekernels, param, model, gpmc, sgpmc, priors, gpr, svgp, vgp, sgpr, gplvm, tf_wraps,
File "/Users/Chu/Documents/GPflow-master/GPflow/likelihoods.py", line 17, in <module>
from . import densities, transforms
File "/Users/Chu/Documents/GPflow-master/GPflow/transforms.py", line 18, in <module>
from . import tf_wraps as tfw
File "/Users/Chu/Documents/GPflow-master/GPflow/tf_wraps.py", line 36, in <module>
_custom_op_module = tf.load_op_library(os.path.join(os.path.dirname(__file__), 'tfops', 'matpackops.so'))
File "/Users/Chu/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/load_library.py", line 64, in load_op_library
None, None, error_msg, error_code)
tensorflow.python.framework.errors_impl.NotFoundError: dlopen(/Users/Chu/Documents/GPflow-master/GPflow/tfops/matpackops.so, 6): image not found
So I think I should try install it under library? Here are some other captures:
I have the same issue even if when I try to install it outside Pycharm. I looked into the reported issue in Github, and the problem was solved for someone else when he built TensorFlow from scratch uisng gcc5
I dont think you can just simply install GPflow on pycharm. Do it outside and then you can use it. Here is the link where it is reported to be solved:
https://github.com/GPflow/GPflow/issues/192
I'm doing work in a conda environment. Today when I entered the environment, IPython failed to run, with the following error:
Traceback (most recent call last):
File "/home/d04/jayat/miniconda3/envs/umiopy/bin/ipython", line 4, in <module>
import IPython
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/core/ultratb.py", line 127, in <module>
from IPython.utils.data import uniq_stable
ImportError: cannot import name uniq_stable
IPython is up to date:
ipython 5.3.0 py27_0
It seems to be searching in the right place:
$ which ipython
~/miniconda3/envs/umiopy/bin/ipython
I'm using conda 4.3.14.
I've not changed anything in the environment but it's possible something has been updated by the system administrators (though it's hard to understand how that could affect my environment). What could be causing this problem? For similar errors on StackOverflow it seems like I'll need to update some module through conda.
If anyone ever experiences this issue, after some period of time, reinstalling iPython resulted in it working. I have no idea what broke it in the first place, and why reinstalling didn't help previously. Some sort of conda-related problem I suppose.
It's this simple:
conda remove ipython
conda install ipython