# Error when calling device()

**URL:** <https://discuss.pennylane.ai/t/error-when-calling-device/259>\
**Category:** PennyLane Help\
**Created:** [October 30, 2019, 9:32am UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259 "2019-10-30T09:32:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![abignu](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/abignu/32/142_2.png) [@abignu](https://discuss.pennylane.ai/u/abignu)\
**Post date:** [October 30, 2019, 9:32am UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/1 "2019-10-30T09:32:24Z")

</div>

Hi, I am having an error when calling the device:

```
DeviceError Traceback (most recent call last)
<ipython-input-41-5e0abc3e2a88> in <module>()
  4 from pennylane.plugins import default_qubit
  5 import matplotlib.pyplot as plt
----> 6 dev = qml.device('default.qubit', wires=1)
  7 
  8 # Set a random seed

/usr/local/lib/python3.6/dist-packages/pennylane/ __init__.py in device(name, *args, **kwargs)
128 
129 raise DeviceError(
--> 130 "Device does not exist. Make sure the required plugin is installed."
131 )
132 

DeviceError: Device does not exist. Make sure the required plugin is installed.

```

How can I solve it?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nathan/32/85_2.png) [@nathan](https://discuss.pennylane.ai/u/nathan)\
**Post date:** [October 30, 2019, 1:11pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/2 "2019-10-30T13:11:48Z")

</div>

Hi @abignu,

🤔 That’s an unusual error. The `default.qubit` plugin shouldn’t need any extra installation (comes pre-packaged within pennylane). My guess would be something has gone wrong with your pennylane install. Can you try the following and tell us the output?

```auto
import pennylane as qml
qml.about()

```

Also, can you try uninstalling and reinstalling it and let me know how that works?

Thanks,  
Nathan

PS you shouldn’t need to directly import the plugin (line 4 of your code). This is handled automatically by the `qml.device` function.

---

<div class="post-metadata">

**Author:** ![abignu](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/abignu/32/142_2.png) [@abignu](https://discuss.pennylane.ai/u/abignu)\
**Post date:** [October 30, 2019, 2:15pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/3 "2019-10-30T14:15:23Z")

</div>

Hi @nathan, thanks for your reply. I was working in Google Colab. I found on another page that restarting the runtime fixes this issue. So I have already fixed it.

Thanks for your time

Agustin

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nathan/32/85_2.png) [@nathan](https://discuss.pennylane.ai/u/nathan)\
**Post date:** [October 30, 2019, 3:20pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/4 "2019-10-30T15:20:15Z")

</div>

Glad you got it working 🙂

---

<div class="post-metadata">

**Author:** ![fmacrae](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@fmacrae](https://discuss.pennylane.ai/u/fmacrae)\
**Post date:** [February 1, 2020, 4:14pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/5 "2020-02-01T16:14:29Z")

</div>

Hi both, I’m having the same error on colab and have tried restarting the runtime a couple of times without success.

The output from qml.about() I get is:

```auto
Version: 0.7.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: None
Author-email: None
License: Apache License 2.0
Location: /usr/local/lib/python3.6/dist-packages
Requires: toml, networkx, numpy, autograd, appdirs, semantic-version, scipy
Required-by: PennyLane-qiskit
Platform info: Linux-4.14.137+-x86_64-with-Ubuntu-18.04-bionic
Python version: 3.6.9
Numpy version: 1.17.5
Scipy version: 1.4.1
Installed devices:

```

This is what I’m doing to install it: [https://colab.research.google.com/drive/1bPipFzEuYgNPLVeJ5HXVP-kpG1o5QFmJ](https://colab.research.google.com/drive/1bPipFzEuYgNPLVeJ5HXVP-kpG1o5QFmJ) which I’m basing on [https://pennylane.ai/install.html](https://pennylane.ai/install.html)

---

<div class="post-metadata">

**Author:** ![fmacrae](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@fmacrae](https://discuss.pennylane.ai/u/fmacrae)\
**Post date:** [February 1, 2020, 4:17pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/6 "2020-02-01T16:17:01Z")

</div>

Ignore me, restarted it again and it works 😊

---

<div class="post-metadata">

**Author:** ![Bayaniblues](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/bayaniblues/32/238_2.png) [@Bayaniblues](https://discuss.pennylane.ai/u/Bayaniblues)\
**Post date:** [March 2, 2020, 6:14pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/7 "2020-03-02T18:14:03Z")

</div>

I had the same problem with google collab, then I used this code snippet to restart runtime

```
import os

def restart_runtime():
  os.kill(os.getpid(), 9)
restart_runtime()

```

Calling qml.about() should have the following output

```
Name: PennyLane
Version: 0.8.1
Summary: PennyLane is a Python quantum machine learning library 
by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: None
Author-email: None
License: Apache License 2.0
Location: /usr/local/lib/python3.6/dist-packages
Requires: appdirs, networkx, scipy, semantic-version, numpy, toml, 
autograd
Required-by: 
Platform info: Linux-4.14.137+-x86_64-with-Ubuntu-18.04-bionic
Python version: 3.6.9
Numpy version: 1.17.5
Scipy version: 1.4.1
Installed devices:
- default.gaussian (PennyLane-0.8.1)
- default.qubit (PennyLane-0.8.1)
- default.tensor (PennyLane-0.8.1)
- default.tensor.tf (PennyLane-0.8.1)
```

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nathan/32/85_2.png) [@nathan](https://discuss.pennylane.ai/u/nathan)\
**Post date:** [March 2, 2020, 6:54pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/8 "2020-03-02T18:54:05Z")

</div>

If you’re working manually in a colab notebook, it should also be sufficient (and probably safer?) to restart the runtime via the available menu commands (i.e., no need to script it in python)

---

<div class="post-metadata">

**Author:** ![angelinaG](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/angelinag/32/148_2.png) [@angelinaG](https://discuss.pennylane.ai/u/angelinaG)\
**Post date:** [June 20, 2020, 5:24pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/9 "2020-06-20T17:24:34Z")

</div>

Thank you so much!  
I faced a similar issue while working in Kaggle.  
Resolved after restarting the runtime environment with your code snippet.  
Only restarting the session didn’t quite help earlier.  
Thank you once again

---

<div class="post-metadata">

**Author:** ![angelinaG](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/angelinag/32/148_2.png) [@angelinaG](https://discuss.pennylane.ai/u/angelinaG)\
**Post date:** [June 20, 2020, 5:25pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/10 "2020-06-20T17:25:37Z")

</div>

Very helpful.  
I had the similar output for qml.about() earlier but resolved after restarting the environment.

---

<div class="post-metadata">

**Author:** ![angelinaG](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/angelinag/32/148_2.png) [@angelinaG](https://discuss.pennylane.ai/u/angelinaG)\
**Post date:** [June 20, 2020, 5:26pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/11 "2020-06-20T17:26:08Z")

</div>

Thank you for posting this query

---

<div class="post-metadata">

**Author:** ![Vineesha](https://avatars.discourse-cdn.com/v4/letter/v/7ab992/32.png) [@Vineesha](https://discuss.pennylane.ai/u/Vineesha)\
**Post date:** [September 23, 2020, 5:09pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/12 "2020-09-23T17:09:28Z")

</div>

Hi, I am having an issue in loading the device default.tensor.tf on Pennylane 0.11.0.

```
dev = qml.device('default.tensor.tf', wires=4)

```

This gives the following error:

```
ImportError: default.tensor device requires TensorNetwork>=0.3

```

This is the complete error message:

```
ModuleNotFoundError Traceback (most recent call last)
C:\ProgramData\Anaconda3\envs\tf-gpu\lib\site- 
packages\pennylane\beta\devices\default_tensor.py in <module>
 26 try:
---> 27 import tensornetwork as tn
  28 ModuleNotFoundError: No module named 'tensornetwork'

During handling of the above exception, another exception occurred:

 ImportError Traceback (most recent call last)
<ipython-input-3-385680400a10> in <module>
----> 1 dev = qml.device('default.tensor.tf', wires=4)

C:\ProgramData\Anaconda3\envs\tf-gpu\lib\site- 
packages\pennylane\ __init__.py in device(name, *args, **kwargs)
182 
183 # loads the plugin device class
--> 184 plugin_device_class = plugin_devices[name].load()
185 
186 if Version(version()) not in 
Spec(plugin_device_class.pennylane_requires):

C:\ProgramData\Anaconda3\envs\tf-gpu\lib\site- 
packages\pkg_resources\ __init__.py in load(self, require, *args, 
**kwargs)
2448 if require:
2449 self.require(*args, **kwargs)
-> 2450 return self.resolve()
2451 
2452 def resolve(self):

C:\ProgramData\Anaconda3\envs\tf-gpu\lib\site-packages\pkg_resources\ __init__.py in resolve(self)
2454 Resolve the entry point from its module and attrs.
2455 """
-> 2456 module = __import__ (self.module_name, fromlist=[' __name__'], level=0)
2457 try:
2458 return functools.reduce(getattr, self.attrs, module)

C:\ProgramData\Anaconda3\envs\tf-gpu\lib\site-packages\pennylane\beta\devices\ __init__.py in <module>
 17 .. currentmodule:: pennylane.beta.devices
 18 """
---> 19 from .default_tensor import DefaultTensor
 20 from .default_tensor_tf import DefaultTensorTF

C:\ProgramData\Anaconda3\envs\tf-gpu\lib\site-packages\pennylane\beta\devices\default_tensor.py in <module>
 31 raise ImportError("default.tensor device requires TensorNetwork>=0.3")
 32 except ImportError as e:
---> 33 raise ImportError("default.tensor device requires TensorNetwork>=0.3")
 34 
 35 

ImportError: default.tensor device requires TensorNetwork>=0.3

```

The error persists even after upgrading my tensorflow version to 2.3.0

```
import tensorflow as tf
print(tf. __version__ )
2.3.0

```

How to resolve this?

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [September 23, 2020, 6:19pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/13 "2020-09-23T18:19:40Z")

</div>

HI @Vineesha! You will need to install [TensorNetwork](https://github.com/google/TensorNetwork) in order to use this device. You can do this via pip:

```auto
pip install tensornetwork==0.3

```

---

<div class="post-metadata">

**Author:** ![Vineesha](https://avatars.discourse-cdn.com/v4/letter/v/7ab992/32.png) [@Vineesha](https://discuss.pennylane.ai/u/Vineesha)\
**Post date:** [September 23, 2020, 6:39pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/14 "2020-09-23T18:39:18Z")

</div>

It works! Thank you 😃

---

<div class="post-metadata">

**Author:** ![Amandeep](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/amandeep/32/385_2.png) [@Amandeep](https://discuss.pennylane.ai/u/Amandeep)\
**Post date:** [October 16, 2020, 8:54am UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/15 "2020-10-16T08:54:38Z")

</div>

DeviceError: Device does not exist. Make sure the required plugin is installed.

Please reply solution. Error is same

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [October 16, 2020, 9:54am UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/16 "2020-10-16T09:54:29Z")

</div>

Hi @Amandeep, what device are you using?

- If you want to use a device from an external plugin, the plugin will need to be separately installed using `pip` before the device is available.

- If you are using PennyLane with Google Colab, you will need to _restart the runtime_ (`Runtime` → `Restart Runtime`) before _any_ PennyLane devices are available.

---

<div class="post-metadata">

**Author:** ![Amandeep](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/amandeep/32/385_2.png) [@Amandeep](https://discuss.pennylane.ai/u/Amandeep)\
**Post date:** [October 16, 2020, 10:23am UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/17 "2020-10-16T10:23:21Z")

</div>

device=qiskit.aer and i am not using google colab.

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [October 16, 2020, 4:24pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/18 "2020-10-16T16:24:29Z")

</div>

> device=qiskit.aer and i am not using google colab.

To access the `qiskit.aer` device, you will need to install the [PennyLane-Qiskit plugin](https://pennylaneqiskit.readthedocs.io), if you haven’t already:

```python
pip install pennylane-qiskit

```

If you _have_ installed the plugin already, then it could be something to do with your system configuration - could you post the output of `qml.about()`?

---

<div class="post-metadata">

**Author:** ![Amandeep](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/amandeep/32/385_2.png) [@Amandeep](https://discuss.pennylane.ai/u/Amandeep)\
**Post date:** [October 17, 2020, 4:29am UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/19 "2020-10-17T04:29:35Z")

</div>

Name: PennyLane  
Version: 0.11.0  
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.  
Home-page: [https://github.com/XanaduAI/pennylane](https://github.com/XanaduAI/pennylane)  
Author: None  
Author-email: None  
License: Apache License 2.0  
Location: c:\users\hp\anaconda3\lib\site-packages  
Requires: numpy, appdirs, scipy, autograd, toml, semantic-version, networkx  
Required-by:  
Platform info: Windows-10-10.0.19041-SP0  
Python version: 3.8.3  
Numpy version: 1.18.5  
Scipy version: 1.5.0  
Installed devices:

- default.gaussian (PennyLane-0.11.0)
- default.qubit (PennyLane-0.11.0)
- default.qubit.autograd (PennyLane-0.11.0)
- default.qubit.tf (PennyLane-0.11.0)
- default.tensor (PennyLane-0.11.0)
- default.tensor.tf (PennyLane-0.11.0)

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [October 18, 2020, 2:19pm UTC](https://discuss.pennylane.ai/t/error-when-calling-device/259/20 "2020-10-18T14:19:57Z")

</div>

@Amandeep it looks like the PennyLane-Qiskit plugin is not installed. You can install it using `pip`:

```auto
pip install pennylane-qiskit

```

[Next page](https://discuss.pennylane.ai/t/error-when-calling-device/259.md?page=2)
