So I'm following a tutorial and making a chatbot in python and I'm using the tflearn and tensorflow modules, and when I run my code I get the following error:
Traceback (most recent call last):
File "/home/user/Coding Projects/chatbot/main.py", line 6, in <module>
import tflearn
File "/home/user/.local/lib/python3.8/site-packages/tflearn/__init__.py", line 4, in <module>
from . import config
File "/home/user/.local/lib/python3.8/site-packages/tflearn/config.py", line 5, in <module>
from .variables import variable
File "/home/user/.local/lib/python3.8/site-packages/tflearn/variables.py", line 7, in <module>
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
ModuleNotFoundError: No module named 'tensorflow.contrib'
I can't figure out how to fix it, and was wondering if someone could help me.
check your tensorflow version(you can to check it like that)
`
import tensorflow as tf
print(tf.__version__)
`
tensorflow contrib was removed from tensorflow 2.0 and its functionallty was moved to other modules.
Related
I have installed tensorflow and tflearn using pip on my windows machine. I am using pyhton 3.6 as it was asked by the tutorial because tflearn has some bug with python 3.7.
I am trying to create a chatbot which reads data from a json fil and while testing my code, I ran into an issue with several exceptions given bellow
when i am trying to run this code
import nltk
from nltk.stem.lancaster import LancasterStemmer
stemer = LancasterStemmer()
import numpy
import tflearn
import tensorflow
import random
import json
with open("intents.json") as file:
data = json.load(file)
print(data)
I am getting the following error
Traceback (most recent call last):
File "c:\Users\win 10\Desktop\chatbot\index.py", line 6, in <module>
import tflearn
File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\__init__.py", line 4, in <module>
from . import config
File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\config.py", line 3, in <module>
import tensorflow as tf
File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
Everything is freshly installed, after some issues with installing TensorFLow. I can't decipher the tracebacks myself, therefore I am hoping some of you guys can help me. Thank you in advance!
It's because tflearn has support for TensorFlow version up to 1.2 only. You can downgrade your TensorFlow version to use the above code.
To downgrade:
pip uninstall protobuf
pip uninstall tensorflow
To install TensorFlow 1.x:
pip install tensorflow==1.15
I am trying to write a simple character recolonization code using convolutional neural network in python on windows. I am following this tutorial. But somehow I am having following error message. I could not find the appropriate reason of this error. It would be helpful for me if anyone can breakdown the error with probable solution.
Using TensorFlow backend.
Traceback (most recent call last):
File "C:/Users/Mahin/PycharmProjects/characterRecognization/Learning/practice.py", line 2, in <module>
from keras.datasets import mnist
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\keras\backend\__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\tensorflow\python\__init__.py", line 59, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\Mahin\PycharmProjects\characterRecognization\venv3.6\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
Check if you have installed CUDA, CUDNN, added them to your PATH variable, and if you have correct versions of them for your Tensorflow version (each Tensorflow version supports only range of CUDA versions), check for example this tutorial for installation.
Also, I guess you try to install it on windows (based on the DLL error), which is quite important to mention.
Check import tensorflow.keras... or import keras...
Keras switched to tensorflow.keras, which is a part of tensorflow>=1.10.0.
Maybe it will help.
i tried import keras but it says:
import keras
Using TensorFlow backend.
Traceback (most recent call last):
File "", line 1, in
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/keras/init.py", line 3, in
from . import utils
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/keras/utils/init.py", line 6, in
from . import conv_utils
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/keras/utils/conv_utils.py", line 9, in
from .. import backend as K
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/keras/backend/init.py", line 89, in
from .tensorflow_backend import *
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/keras/backend/tensorflow_backend.py", line 5, in
import tensorflow as tf
File "/Users/elanchezhian/tensorflow.py", line 2, in
from tensorflow.examples.tutorials.mnist import input_data
ModuleNotFoundError: No module named 'tensorflow.examples'; 'tensorflow' is not a package
i am using mac os high sierra and i am running keras in python3 and i installed keras with pip
edit: ok ,i already had a file named tensorflow.py ,i removed it and new error came
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/init.py", line 3, in
from . import utils
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/init.py", line 6, in
from . import conv_utils
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in
from .. import backend as K
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/backend/init.py", line 89, in
from .tensorflow_backend import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in
import tensorflow as tf
ImportError: bad magic number in 'tensorflow': b'\x03\xf3\r\n'
edit: i have removed tensorflow.pyc now this error came :
RuntimeError: module compiled against API version 0xc but this version
of
numpy is 0xb
ImportError: numpy.core.multiarray failed to import
ImportError: numpy.core.umath failed to import
ImportError: numpy.core.umath failed to import
2018-10-21 10:53:26.723451: F
tensorflow/python/lib/core/bfloat16.cc:675]
Check failed: PyBfloat16_Type.tp_base != nullptr
Abort trap: 6
Your script is named tensorflow.py, which conflicts with the name of the real tensorflow package. Name your script something else.
How about generate new virtualenv than 'tensorflow'?
I recommend to generate new virtualenv named 'venv' for example.
In my Anaconda environment, I have same problem but after generating new one, it solved.
when generate 'tensorflow' virtualenv, I had same moduleerror like you.
$ conda create -n venv pip python=3.6
$ source activate venv
(venv)$
But after generating new virtualenv, it works successfully.
I hope your code will work successfully too.
I am trying out YOLO tutorial at https://github.com/llSourcell/YOLO_Object_Detection
When I do the step:
flow --h
I got this error:
File "/anaconda2/bin/flow", line 4, in <module>
from darkflow.cli import cliHandler
ImportError: No module named darkflow.cli
I have tried to find solution everywhere but no luck. Then I tried skip that line and continue...
flow --model cfg/yolo-new.cfg --load bin/yolo-tiny.weights --train --gpu 1.0
I got this error:
Traceback (most recent call last):
File "flow", line 4, in <module>
from darkflow.cli import cliHandler
File "./YOLO_Object_Detection/darkflow/cli.py", line 3, in <module>
from .net.build import TFNet
File "./YOLO_Object_Detection/darkflow/net/build.py", line 7, in <module>
from .framework import create_framework
File "./YOLO_Object_Detection/darkflow/net/framework.py", line 1, in <module>
from . import yolo
File "./YOLO_Object_Detection/darkflow/net/yolo/__init__.py", line 2, in <module>
from . import predict
File "./YOLO_Object_Detection/darkflow/net/yolo/predict.py", line 7, in <module>
from ...cython_utils.cy_yolo_findboxes import yolo_box_constructor
File "darkflow/cython_utils/cy_yolo_findboxes.pyx", line 1, in init darkflow.cython_utils.cy_yolo_findboxes
import numpy as np
ModuleNotFoundError: No module named 'nms'
Any help appreciated. Thank you
Both problems are discussed at the issue tracker.
*ImportError: No module named darkflow.cli
https://github.com/llSourcell/YOLO_Object_Detection/issues/3
You have to build the cython modules:
cd ./cython_utils
python3 setup.py build_ext --inplace
cd ..
ModuleNotFoundError: No module named 'nms'
https://github.com/llSourcell/YOLO_Object_Detection/issues/7
See https://keponk.wordpress.com/2017/12/07/siraj-darkflow/ for installation using conda.
When i import tflearn in Python, it says ModuleNotFoundError: No module named 'tensorflow.contrib.framework', does someone know how to deal with this issue? Thanks.
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\User\Anaconda3\lib\site-packages\tflearn_init_.py", line 4, in
from . import config
File "C:\Users\User\Anaconda3\lib\site-packages\tflearn\config.py", line 5, in
from .variables import variable
File "C:\Users\User\Anaconda3\lib\site-packages\tflearn\variables.py", line 7, in
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
ModuleNotFoundError: No module named 'tensorflow.contrib.framework'
The error message suggests the module is not installed/found.
For example, I do not have tflearn installed, but I have tensorflow installed.
>>> from tensorflow.contrib.framework.python.ops import add_arg_scope
>>> import tflearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tflearn'
Try importing the whole tensorflow module and see if you are getting the same error. If so, try reinstalling the tensorflow module.