Cannot import Pennylane - ImportError: cannot import name 'dataclass_transform' from 'typing_extensions'

I can’t seem to import pennylane. I tried all my IDE’s and they all give me the same long error. I consulted chatGPT about what it could be but just told me to make sure a bunch of stuff was up to date, which it was. I installed pennylane today using pip. Any help or insight would be immensely appreciated!

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-20-45f1fb5914cd> in <module>
      1 import numpy as np
----> 2 import pennylane as qml

~\anaconda3\lib\site-packages\pennylane\__init__.py in <module>
    130 import pennylane.logging  # pylint:disable=wrong-import-order
    131 
--> 132 import pennylane.data
    133 
    134 # Look for an existing configuration file

~\anaconda3\lib\site-packages\pennylane\data\__init__.py in <module>
    195 """
    196 
--> 197 from .attributes import (
    198     DatasetArray,
    199     DatasetDict,

~\anaconda3\lib\site-packages\pennylane\data\attributes\__init__.py in <module>
     15 
     16 from .array import DatasetArray
---> 17 from .dictionary import DatasetDict
     18 from .json import DatasetJSON
     19 from .list import DatasetList

~\anaconda3\lib\site-packages\pennylane\data\attributes\dictionary.py in <module>
     22 from pennylane.data.base.attribute import DatasetAttribute
     23 from pennylane.data.base.hdf5 import HDF5Any, HDF5Group
---> 24 from pennylane.data.base.mapper import MapperMixin
     25 from pennylane.data.base.typing_util import T
     26 

~\anaconda3\lib\site-packages\pennylane\data\base\__init__.py in <module>
     16 
     17 from .attribute import AttributeInfo, DatasetAttribute
---> 18 from .dataset import Dataset, field
     19 from .mapper import DatasetNotWriteableError
     20 

~\anaconda3\lib\site-packages\pennylane\data\base\dataset.py in <module>
     37 
     38 # pylint doesn't think this exists
---> 39 from typing_extensions import dataclass_transform  # pylint: disable=no-name-in-module
     40 
     41 from pennylane.data.base import hdf5

ImportError: cannot import name 'dataclass_transform' from 'typing_extensions' (C:\Users\James\anaconda3\lib\site-packages\typing_extensions.py)

Hey @PulsarDude! Welcome to the forum :smiley:

I recommend trying to install PennyLane on a fresh environment. I see that you’re using Conda, so you can create a virtual environment with conda with help from that link. Once you create a “blank-slate” environment, try installing PennyLane again.

Let me know if that helps!

1 Like

Works perfectly now! Thanks a million!

1 Like

Awesome! Glad I was able to help :slight_smile: