tensorflow / datasets

TFDS is a collection of datasets ready to use with TensorFlow, Jax, ...
https://www.tensorflow.org/datasets
Apache License 2.0
4.3k stars 1.54k forks source link

cannot import tensorflow_datasets #5097

Closed ashrafbadalof closed 1 year ago

ashrafbadalof commented 1 year ago

What I need help with / What I was wondering ImportError: cannot import name 'core' from partially initialized module 'tensorflow_datasets' (most likely due to a circular import) (C:\Users\ASUS\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow_datasets__init__.py) Encountering with this issue

What I've tried so far I tried nearly everything, i uninstalled and then installed again, created new environment but didn't work out

It would be nice if... Could we have done anything to make things better (documentation, etc.)?

Environment information (if applicable)

Tishachhabra commented 1 year ago

I am having the same issue!

AQUIN0S commented 1 year ago

I'm guessing you're running it in Windows? I had hit this when trying to resolve the issue No module named 'resource' and going through the Stack Overflow recommendation. That recommendation might be a bit off I think.

I believe this has been fixed now, but the fix hasn't yet been released, in commit https://github.com/tensorflow/datasets/commit/82215c7cf4b3e6df706a72c9b7ad8cede09f4d84

If you update your shuffle.py (mine's located in venv\Lib\site-packages\tensorflow_datasets\core\shuffle.py) with the changes in that commit, it should go through.

fineguy commented 1 year ago

Sorry to hear about your problem.

The fix is yet to be released, but is already available in tfds-nightly.

Could you try using pip install --upgrade --force-reinstall tfds-nightly?

a-a-k commented 1 year ago

how to use tfds-nightly build? same as tensorflow_datasets - import tfds-nightly as tfds?

fineguy commented 1 year ago

No, after installing tfds-nightly package you continue using TFDS normally, i.e. import tensorflow_datasets as tfds.

a-a-k commented 1 year ago

No, after installing tfds-nightly package you continue using TFDS normally, i.e. import tensorflow_datasets as tfds.

Hmm.. But I'm still getting ImportError: cannot import name 'core' from partially initialized module 'tensorflow_datasets' (most likely due to a circular import) (C:\Users\aak\venv\lib\site-packages\tensorflow_datasets\__init__.py)

fineguy commented 1 year ago

Could you please share the full error log?

a-a-k commented 1 year ago

Could you please share the full error log?

sure

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[4], line 2
      1 import tensorflow as tf
----> 2 import tensorflow_datasets as tfds

File ~\Desktop\venv\lib\site-packages\tensorflow_datasets\__init__.py:43
     41 _TIMESTAMP_IMPORT_STARTS = time.time()
     42 from absl import logging
---> 43 import tensorflow_datasets.core.logging as _tfds_logging
     44 from tensorflow_datasets.core.logging import call_metadata as _call_metadata
     46 _metadata = _call_metadata.CallMetadata()

ImportError: cannot import name 'core' from partially initialized module 'tensorflow_datasets' (most likely due to a circular import) (C:\Users\aak\Desktop\venv\lib\site-packages\tensorflow_datasets\__init__.py)
a-a-k commented 1 year ago

I've just updated tfds, btw image

fineguy commented 1 year ago

Do you have a traceback in your error log?

mriganksoni commented 1 year ago

I am also going through the exact same problem, is there any update on solution.

fineguy commented 1 year ago

@mriganksoni have you tried using the most recent tfds-nightly package? If so, could you share a traceback for your error?

mriganksoni commented 1 year ago

hi, i tried installing tfds nightly using pip install tfds-nightly --no-cache-dir --force-reinstall --upgrade and it then it worked.

ItsVanior commented 1 year ago

I haI have the same problem. And if I want to fix it with pip install tfds-nightly --no-cache-dir --force-reinstall --upgrade it installs it. But this led to an upgraded version of tensorboard which is not compatible with tensorflow. I'm using Tensorflow 2.10 for GPU support. Is this not compatible with Tensorflow_Datasets ? Does someone have some advice for me?

fineguy commented 1 year ago

@ItsVanior tensorflow-datasets requires tensorflow>=2.1 and doesn't restrict your tensorboard version, so feel free to downgrade it if necessary.

ItsVanior commented 1 year ago

My bad. I forgot to write that Protobuf get an upgrade as well, which is not compatible with tensorflow.

fineguy commented 1 year ago

@ItsVanior tensorflow-datasets requires protobuf>=3.20. You should handle all other dependency versions yourself.

jamesmyatt commented 12 months ago

What's the plan for releasing a bug fix version that includes this?

vinnamkim commented 11 months ago

Is there any update for the release to fix this bug?

naranjitoct commented 11 months ago

I have the same issue when trying to import keras_cv First of all I notice a message that No module named 'resource' when trying to import this library from shuffle.py.

image

I looked for a solution and when executing "pip install resource" or modifiying the shuffle.py to add code with exception (see https://github.com/tensorflow/datasets/commit/82215c7cf4b3e6df706a72c9b7ad8cede09f4d84) then I noticed a (i think) worst issue because import tensorflow_datasets.core.logging as _tfds_logging then fails (and it previosly didn't do.

I am not familiar with this IDE as I started with GoogleColab notebooks but I wanted to move to a more "local" enviroment but I am on hold...

KevinRetrive commented 10 months ago

I have done the "pip install tfds-nightly --no-cache-dir --force-reinstall --upgrade" but I recieved the next ERROR

image

And still I have the same problem to import tensorflow_datasets ImportError: cannot import name 'core' from partially initialized module 'tensorflow_datasets' (most likely due to a circular import) (C:\Users\ASUS\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow_datasetsinit.py)