cannot import name '_RNNCell' - python-3.x

I run the following code using the pyton3:
from tensorflow.python.ops.rnn_cell_impl import _RNNCell as RNNCell
The error was:
ImportError: cannot import name '_RNNCell'
Does anyone know how to solve this?

Check the version of tf and downgrade it based on the version it is available in.

Related

ImportError: cannot import name '_print_elapsed_time'

Hi so I'm trying to use the make_pipeline module in sklearn. But when I try to import it with:
from sklearn.pipeline import make_pipeline
I get this error:
ImportError: cannot import name '_print_elapsed_time'
I've googled it but there seems to be no other posts about this. I tried reinstalling scikitlearn but I still get the same error :/ Anyone have any ideas?
It looks like this was a bug introduced into one of the newer versions of scikit-learn (I got this same issue in version 0.21.2).
I was able to fix this by downgrading to scikit-learn version 0.20.0
>> pip install scikit-learn==0.20.0

How to import WordEmbeddingSimilarityIndex function from gensim module?

When i try to import WordEmbeddingSimilarityIndex, it's giving me the following error:
>> from gensim.models import WordEmbeddingSimilarityIndex
ImportError: cannot import name 'WordEmbeddingSimilarityIndex
The same issue occurs for SparseTermSimilarityMatrix function:
>> from gensim.similarities import SparseTermSimilarityMatrix
ImportError: cannot import name 'SparseTermSimilarityMatrix
Note: I have installed and imported gensim, gensim.models and gensim.similarities. But still it's giving me the ImportError while importing the above mentioned functions.
Can you tell me what I am doing wrong, please?
Fix is change "models" to "similarities"
from gensim.similarities import WordEmbeddingSimilarityIndex
it works in gensim 4.0.1
Try to check the version of gensim that you are using. Usually, the older versions of gensim cause this issue.
from gensim.models import WordEmbeddingSimilarityIndex
print(gensim.__version__)
if the gensim version is 3.6.x or older update it to 3.7.x or latest version by running the below command. Once you update gensim version should get rid of this issue.
pip install --upgrade gensim

How to fix "ImportError: cannot import name 'flags' " while importing flags from Cleverhans.compat in Python

I am having a problem while playing the following code given as example in Cleverhans Library :
The problem is on Line # 18 . When it plays it gives out an import error :
ImportError: cannot import name 'flags'
I have tried to see in the help and there is also no flags function listed there.
from cleverhans.compat import flags
This should work by simply importing the module and giving no error.
I found the solution.
If any such error appears then its due to the problem in the way you have set your environment to work in .
If the dependencies are perfectly aligned then there comes no such error.
Thanks :)
P.S. If you find such error while running your code in Cleverhans then drop me a message . I'll be happy to help :)
To anyone that needs a solution:
replace from cleverhans.compat import flags with from tensorflow.python.platform import flags
if you are using pycharm, maybe you should open all the project 'cleverhans-master', and right-click on it,select mark directory as---source root. And it could be imported normally.

cannot import name 'convert_saved_model'

I am trying to convert a frozen grap to tflite using convert_saved_model in tensorflow, but i am getting the following error
from tensorflow.contrib.lite.python import convert_saved_model
ImportError: cannot import name 'convert_saved_model'
Here's the code i've been using
from tensorflow.contrib.lite.python import convert_saved_model
convert_saved_model.tflite_from_saved_model(saved_model_dir="optimized_graph.pb",
output_file="/tflite_Model")
I am using a Windows 8.1 and tensorflow 1.8.
I've tried using toco_convert but got the error
module tensorflow.contrib has no attribute 'lite'
Please try with Tensorflow 1.9 and file a Github issue if this is still not working https://github.com/tensorflow/tensorflow/issues

python3 ImportError: cannot import name

I work in Ubuntu16.04 x64 use python3.5 IDEA
but I got a strange question as in picture,I try rename connect,but it can't work.
How should I solve this problem? Please tell me if you known,thinks.
Try the following:
from .tpymysql import connect
I think there is something likeclass Connect() in your connect.py.
If the script to be executed is under the same path to connect.py
from connect import Connect
Else
from tpymysql.connect import Connect
The Pythonic way is making everything clear and specific. So when you want to import something, import what's inside other than the file itself.
Python3 usually throws this ImportError for relative imports. Seems relative imports are not necessary.
Try:
import tpymysql

Resources