GitHub issue #6753: Type error when importing datasets on Kaggle
State: closed | Created: 2024-03-24T03:01:30Z

### Describe the bug

When trying to run
```
import datasets
print(datasets.__version__)

```
It generates the following error

```
TypeError: expected string or bytes-like object
```

It looks like It cannot find the valid versions of `fsspec`

though fsspec version is fine when I checked Via command

```
import fsspec
print(fsspec.__version__)
​
# output: 2024.3.1
```

Detailed crash report
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 import datasets
      2 print(datasets.__version__)

File /opt/conda/lib/python3.10/site-packages/datasets/__init__.py:18
      1 # ruff: noqa
      2 # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors.
      3 #
   (...)
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     16 __version__ = "2.18.0"
---> 18 from .arrow_dataset import Dataset
     19 from .arrow_reader import ReadInstruction
     20 from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder

File /opt/conda/lib/python3.10/site-packages/datasets/arrow_dataset.py:66
     63 from multiprocess import Pool
     64 from tqdm.contrib.concurrent import thread_map
---> 66 from . import config
     67 from .arrow_reader import ArrowReader
     68 from .arrow_writer import ArrowWriter, OptimizedTypedSequence

File /opt/conda/lib/python3.10/site-packages/datasets/config.py:41
     39 # Imports
     40 DILL_VERSION = version.parse(importlib.metadata.version("dill"))
---> 41 FSSPEC_VERSION = version.parse(importlib.metadata.version("fsspec"))
     42 PANDAS_VERSION = version.parse(importlib.metadata.version("pandas"))
     43 PYARROW_VERSION = version.parse(importlib.metadata.version("pyarrow"))

File /opt/conda/lib/python3.10/site-packages/packaging/version.py:49, in parse(version)
     43 """
     44 Parse the given version string and return either a :class:`Version` object
     45 or a :class:`LegacyVersion` object depending on if the given version is
     46 a valid PEP 440 version or a legacy version.
     47 """
     48 try:
---> 49     return Version(version)
     50 except InvalidVersion:
     51     return LegacyVersion(version)

File /opt/conda/lib/python3.10/site-packages/packaging/version.py:264, in Version.__init__(self, version)
    261 def __init__(self, version: str) -> None:
    262 
    263     # Validate the version and parse it into pieces
--> 264     match = self._regex.search(version)
    265     if not match:
    266         raise InvalidVersion(f"Invalid version: '{version}'")

TypeError: expected string or bytes-like object
```


### Steps to reproduce the bug

1. run `!pip install -U datasets` on kaggle
2. check datasets is installed via
```
import datasets
print(datasets.__version__)
```

### Expected behavior

Expected to print datasets version, like `2.18.0`

### Environment info

Running on Kaggle, latest enviornment , here is the notebook https://www.kaggle.com/code/jtv199/mistrial-7b-part2