Error in platformdirs import

I code:

dev = qml.device("default.qubit", wires=4)

I got the following error:

ImportError: cannot import name 'platformdirs' from 'pkg_resources.extern'

The platform is Python 3.11. Is Pennylane compatible with Python 3.11?
Thanking you in advance

Hello salmeron! Welcome to the PennyLane community!

I have checked, and PennyLane does work for me with Python 3.11! I am using version 0.28.0 of PennyLane, have you updated PennyLane itself? If you have, then it’s not a version compatibility issue. You can also use the Notebooks within Xanadu Cloud to avoid these dependency problems :slight_smile:

Let me know if this helps!

Alvaro

Many thanks Alvaro! I updated PennyLane but the issue still there. I am using an Apple with a M2 microprocessor. Maybe it is the problem. Do you have any information about issues with M2 computers? Thanking you in advance

Hi @salmeron,

You’re right that the M2 might be the issue.

Could you please post the output of qml.about()?

As Alvaro mentioned you can use Xanadu Cloud in the meantime but I hope we can get your issue resolved too.

Sorry for the late reply. Surprisingly it’s working fine right now. Anyway, the output of qml.about() is as follows:
Name: PennyLane
Version: 0.28.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: GitHub - PennyLaneAI/pennylane: PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.
Author:
Author-email:
License: Apache License 2.0
Location: /Users/hal9002/Development/Quantum/XAI-QML/lib/python3.11/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning
Platform info: macOS-13.2.1-arm64-arm-64bit
Python version: 3.11.2
Numpy version: 1.23.5
Scipy version: 1.10.0
Installed devices:

  • default.gaussian (PennyLane-0.28.0)
  • default.mixed (PennyLane-0.28.0)
  • default.qubit (PennyLane-0.28.0)
  • default.qubit.autograd (PennyLane-0.28.0)
  • default.qubit.jax (PennyLane-0.28.0)
  • default.qubit.tf (PennyLane-0.28.0)
  • default.qubit.torch (PennyLane-0.28.0)
  • default.qutrit (PennyLane-0.28.0)
  • null.qubit (PennyLane-0.28.0)
  • lightning.qubit (PennyLane-Lightning-0.28.2)

Hi @salmeron,

I’m glad that this works now! There may have been an issue with an external library. Thanks anyway for sharing these details and it’s good to know that there are no known issues with Apple M2 at the moment :sunglasses:.

Enjoy using PennyLane!

Thank you @CatalinaAlbornoz! It is great to know.