error when I try to import tflearn : cannot import name 'is_sequence' from 'tensorflow.python.util.nest'

4.3k views Asked by At

I already have tflearn installed and I get the following error when I try to import it:

ImportError: cannot import name 'is_sequence' from 'tensorflow.python.util.nest' (C:\Users\fsafi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorflow\python\util\nest.py)

I tried the following:

import tflearn
3

There are 3 answers

0
Thomas Choy On

I have encountered exactly the same issue when setting up a new tf environment. I believe it is because tflearn==0.5.0 which is too old and cannot work with latest tensorflow=2.13.0.

I have to fall back tensorflow to older version such as 2.12.0 to make it works.

There is also a PR on tflearn to fix this problem but it is still work in progress: https://github.com/tflearn/tflearn/pull/1173/commits

Basically is_sequence(args) will be replaced with is_sequence_or_composite(args).

from tensorflow.python.util.nest import is_sequence_or_composite
if args is None or (is_sequence_or_composite(args) and not args):
 raise ValueError("`args` must be specified")
if not is_sequence_or_composite(args):
 args = [args]

Besides, the Pillow-10.0 gave the same issue which can be fixed by replacing it with Pillow-9.5 or you can replace the ANTIALIAS with LANCZOS by the utils.py file like we did for the reccurent.py file of tflearn library.

pip uninstall Pillow
pip install Pillow==9.5.0

I just uploaded the previous version of PIL and it totally works right now.

0
Archit Anant On

I encountered the same issue! See, if you don't want to go back to old Tensorflow versions try these:

  1. Fork the Tflearn repo https://github.com/tflearn/tflearn
  2. See the updates in one the pull requests (https://github.com/tflearn/tflearn/pull/1173) of this repo
  3. Make these changes in your forked repo
  4. The uninstall Tflearn and then reinstall tflearn from your forked repo
  • Just do pip install git+https://github.com/<your_github_user_name>/<forked_repo_name>.git
1
AlASAD WAIL On

According to this: You can solve the issue by running:

pip uninstall tflearn
pip install git+https://github.com/MihaMarkic/tflearn.git@fix/is_sequence_missing