ImportError: cannot import name 'SimpleSpec' from 'semantic_version'

I have been using pennylane for quantum circuit building, but while compiling I am getting the following error:

Traceback (most recent call last):
  File "/home/shuhul.handoo/shuhul/code/", line 2, in <module>
    from models import build_generator, build_discriminator
  File "/home/shuhul.handoo/shuhul/code/", line 9, in <module>
    from penn import quantum_layr
  File "/home/shuhul.handoo/shuhul/code/", line 1, in <module>
    import pennylane as qml
  File "/home/shuhul.handoo/anaconda3/lib/python3.9/site-packages/pennylane/", line 25, in <module>
    from semantic_version import SimpleSpec, Version
ImportError: cannot import name 'SimpleSpec' from 'semantic_version' (/home/shuhul.handoo/anaconda3/lib/python3.9/site-packages/semantic_version/

First I thought this was error with installing Pennylane using pip but after installing pennylane using the command conda install -c conda-forge pennylane I still get this error. What should be done?

Hi @shuhul, welcome to the forum!

I do think this is an installation issue. Please try creating a new environment following the step-by-step below:

Create a new conda environment with:
conda create --name name_of_your_environment python=3.9
Activate the environment:
conda activate name_of_your_environment
After this you can install the needed packages:
python -m pip install pennylane

Please let me know if this works for you!