Error when importing Tensorflow in my project - python

My project is in Python 3.7, anaconda Jupyter Notebook on windows 10.
When I try to import Tensorflow i get the following error message:
>>> import tensorflow as tf
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import tensorflow as tf
File "C:\Users\Guilherme\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py", line 98, in <module>
from tensorflow_core import *
File "C:\Users\Guilherme\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\__init__.py", line 42, in <module>
from . _api.v2 import audio
File "C:\Users\Guilherme\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\_api\v2\audio\__init__.py", line 10, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "C:\Users\Guilherme\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\ops\gen_audio_ops.py", line 7, in <module>
import six as _six
ModuleNotFoundError: No module named 'six'
>>>
I have tried to install this 'six', but it says "Requeriments already satisfied"
What should I do?

Related

sklearn.utils module is not found

So I have sklearn installed, but for some reason whenever I try to import sklearn it says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\joeya\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\joeya\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
ModuleNotFoundError: No module named 'sklearn.utils'
Does anyone have any ideas? I have Python 3.8.7 installed.

ImportError: cannot import name 'Type' when importing 'gensim"

I want to import the "genism" library. I have previously successfully installed it by typing the following in the command prompt:
pip install gensim
However, the following error appears when importing it:
Traceback (most recent call last):
File "C:/Users/PycharmProjects/untitled/file.py", line 3, in <module>
import gensim
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\parsing\__init__.py", line 4, in <module>
from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\parsing\preprocessing.py", line 42, in <module>
from gensim import utils
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\utils.py", line 40, in <module>
import scipy.sparse
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\__init__.py", line 156, in <module>
from . import fft
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\fft\__init__.py", line 76, in <module>
from ._basic import (
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\fft\_basic.py", line 1, in <module>
from scipy._lib.uarray import generate_multimethod, Dispatchable
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\uarray.py", line 27, in <module>
from ._uarray import *
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\_uarray\__init__.py", line 114, in <module>
from ._backend import *
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\_uarray\_backend.py", line 1, in <module>
from typing import (
ImportError: cannot import name 'Type'
I have also previously successfully installed the "typing" library":
pip install typing
What should I do?
It is because Python 3.5 has its own version typing, and it is incompatible with the installed version of gensim. Upgrade to python3.6 could solve the problem.

keras installation error: No module named 'tensorflow.python.tools'

I am trying to use keras.models. Here is the code I have in a python script
import keras.models
Running it gives me this error:
Using TensorFlow backend.
Traceback (most recent call last):
File "test.py", line 1, in <module>
import keras.models
File "/usr/local/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/usr/local/lib/python3.7/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/usr/local/lib/python3.7/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/usr/local/lib/python3.7/site-packages/keras/backend/__init__.py", line 1, in <module>
from .load_backend import epsilon
File "/usr/local/lib/python3.7/site-packages/keras/backend/load_backend.py", line 90, in <module>
from .tensorflow_backend import *
File "/usr/local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/usr/local/lib/python3.7/site-packages/tensorflow/__init__.py", line 101, in <module>
from tensorflow_core import *
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package
I have tried uninstalling and reinstalling keras as well as installing keras.models seperately however in both cases I still get this error. Why is this? Thanks
The problem is with your Tensorflow, re-install that.

Seaborn import error

I have been trying to import Seaborn in Python 3.6 but I always get an error:
ImportError: DLL load failed: The specified module could not be found.
I tried to install 2 DLLs (msvcp71 and msvcr71) but that did not help. I am using Windows 10.
The full error is:
import seaborn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Python36\lib\site-packages\seaborn\rcmod.py", line 8, in <module>
from . import palettes, _orig_rc_params
File "C:\Python36\lib\site-packages\seaborn\palettes.py", line 12, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Python36\lib\site-packages\seaborn\utils.py", line 7, in <module>
from scipy import stats
File "C:\Python36\lib\site-packages\scipy\stats\__init__.py", line 343, in <module>
from .stats import *
File "C:\Python36\lib\site-packages\scipy\stats\stats.py", line 169, in <module>
import scipy.special as special
File "C:\Python36\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
The problem was in Scipy so I uninstalled (pip uninstall) it and then reinstalled Scipy. Also reinstalled seaborn. That worked.
Trying to install from .whl didn't work but pip worked.

I got an error when I wanted to use tensorflow

I got an error when I wanted to use tensorflow.
I just installed tensorflow and I did
$ source activate tensorflow
command, terminal became tensorflow version like
(tensorflow) ~   master 
But I wrote sample.py like
import tensorflow as tf
import multiprocessing as mp
core_num = mp.cpu_count()
config = tf.ConfigProto(
inter_op_parallelism_threads=core_num,
intra_op_parallelism_threads=core_num )
sess = tf.Session(config=config)
hello = tf.constant('hello, tensorflow!')
print sess.run(hello)
a = tf.constant(10)
b = tf.constant(32)
print sess.run(a+b)
and I run this script like python rote sample.py
so this error happen
Traceback (most recent call last):
File "test.py", line 1, in <module>
import tensorflow as tf
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
from tensorflow.python import *
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 13, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"d\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tb\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
So I searched this error, and I found this solution.
https://github.com/tensorflow/tensorflow/issues/11
I wanna do
pip uninstall protobuf
pip uninstall tensorflow
brew uninstall protobuf
pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
commands, but only brew uninstall protobuf command could not be done.
So,I did 3 commands and I did python rote sample.py again, but almost same error happen.
Traceback (most recent call last):
File "test.py", line 1, in <module>
import tensorflow as tf
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
from tensorflow.python import *
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 13, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/Users/username/tensorflow/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"d\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tb\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
What should I do to fix this?
Furthermore,why this error happen?What is wrong?
i just upgraded protobuf to the latest version and it worked for me
pip install protobuf --upgrade

Categories

Resources