Unexpected keyword argument 'noise_model' - python

The following code throws an error. Based on some issues that I read on qiskit github, it seems that it has something do with run configs vs. compile configs but I could not find any other info that will help me resolve this issue.
from qiskit import QuantumCircuit, IBMQ, execute
from qiskit import BasicAer as Aer
from qiskit.providers.aer import noise
ckt = QuantumCircuit(2, 2)
ckt.h(0)
ckt.cx(0, 1)
ckt.measure(0, 0)
ckt.measure(1, 1)
qsim = Aer.get_backend("qasm_simulator")
IBMQ.load_account()
provider = IBMQ.get_provider(hub="ibm-q")
qc = provider.get_backend("ibmqx2")
props = qc.properties()
coupling_map = qc.configuration().coupling_map
noise_model = noise.device.basic_device_noise_model(props)
job = execute(
ckt,
qsim,
noise_model=noise_model,
coupling_map=coupling_map,
basis_gates=noise_model.basis_gates
)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-2f987d65d1f7> in <module>
25 noise_model=noise_model,
26 coupling_map=coupling_map,
---> 27 basis_gates=noise_model.basis_gates
28 )
~/.venvs/qk/lib/python3.7/site-packages/qiskit/execute.py in execute(experiments, backend, basis_gates, coupling_map, backend_properties, initial_layout, seed_transpiler, optimization_level, pass_manager, qobj_id, qobj_header, shots, memory, max_credits, seed_simulator, default_qubit_los, default_meas_los, schedule_los, meas_level, meas_return, memory_slots, memory_slot_size, rep_time, parameter_binds, **run_config)
220
221 # executing the circuits on the backend and returning the job
--> 222 return backend.run(qobj, **run_config)
TypeError: run() got an unexpected keyword argument 'noise_model'
Env:
macOS 10.14.6
Python 3.7.3
qiskit 0.12.0

The error is coming up because you are using BasicAer to retrieve the simulator backend. I do not think this will work with the BasicAer provider. You should be using the Aer provider.
from qiskit import Aer
qsim = Aer.get_backend('qasm_simulator')
If you just change your import statement from
from qiskit import BasicAer as Aer
to
from qiskit import Aer
then your code should work

Related

importing dask_cuda results in parse_memory_limit error

I'm trying to import dask_cuda as the examples:
from dask_cuda import LocalCUDACluster
from dask.distributed import Client
But I receive the following error:
ImportError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 from dask_cuda import LocalCUDACluster
File ~/miniconda3/lib/python3.8/site-packages/dask_cuda/__init__.py:5, in <module>
2 import dask.dataframe.shuffle
4 from ._version import get_versions
----> 5 from .cuda_worker import CUDAWorker
6 from .explicit_comms.dataframe.shuffle import get_rearrange_by_column_tasks_wrapper
7 from .local_cuda_cluster import LocalCUDACluster
File ~/miniconda3/lib/python3.8/site-packages/dask_cuda/cuda_worker.py:19, in <module>
14 from distributed.proctitle import (
15 enable_proctitle_on_children,
16 enable_proctitle_on_current,
17 )
18 from distributed.utils import parse_bytes
---> 19 from distributed.worker import parse_memory_limit
21 from .device_host_file import DeviceHostFile
22 from .initialize import initialize
ImportError: cannot import name 'parse_memory_limit' from 'distributed.worker' (/home/shambakey1/miniconda3/lib/python3.8/site-packages/distributed/worker.py)
I googled this error, but couldn't find anything related to it. I thought it was a DASK problem, so I re-tried with only from dask.distributed import Client, and it worked. So, I guess this error is related to dask_cuda, but I don't know how.
The version I have are:
dask-cuda -> 22.6.0
dask -> 2021.12.0
distributed -> 2021.12.0
Ubuntu 20.04
Regards
Your dask version is rather old, the parse_memory_limit was added fairly recently in 2022, see this PR.
I would recommend not pinning dask and let conda find the most suitable version. If that's not an option, then dask=2022.7.0 works for me with dask-cuda=2022.6.0.

TypeError: configurable() got an unexpected keyword argument 'denylist'

I installed the package, but I cannot import it. I get this error:
TypeError: configurable() got an unexpected keyword argument 'denylist'
I appreciate it if you could help me to fix this.
Below you can see the complete error that I got.
import trax
I installed this package(Deep learning package), and when I import it, I get this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-3afdcd9c7c68> in <module>
----> 1 import trax
~/opt/anaconda3/lib/python3.7/site-packages/trax/__init__.py in <module>
16 """Trax top level import."""
17
---> 18 from trax import data
19 from trax import fastmath
20 from trax import layers
~/opt/anaconda3/lib/python3.7/site-packages/trax/data/__init__.py in <module>
18
19 from trax.data import inputs
---> 20 from trax.data import tf_inputs
21
22
~/opt/anaconda3/lib/python3.7/site-packages/trax/data/tf_inputs.py in <module>
504
505 # Makes the function accessible in gin configs, even with all args denylisted.
--> 506 #gin.configurable(denylist=['dataset', 'training'])
507 def cifar10_no_augmentation_preprocess(dataset, training):
508 del training
TypeError: configurable() got an unexpected keyword argument 'denylist'
I really need to work with this package, and I don't know how to fix it.
My OS: macOS Big Sur
Python version: Python 3.7.4
I found the solution:
!pip install --upgrade -q gin git+https://github.com/google/trax.git#v1.2.3

Bokeh Error when making simple widget in Python

I keep getting this ImportError for just trying to set up a basic widget slider. Below is the input and error message.
import bokeh
from bokeh.io import output_notebook, show
import bokeh.models.widgets
from bokeh.models.widgets import Slider
slider = Slider(start = 0, end = 10 , value = 1, step=.1, title = 'do nothing')
show(slider)
ImportError Traceback (most recent call last)
<ipython-input-100-2c4894dccaf0> in <module>()
10 slider = Slider(start = 0, end = 10 , value = 1, step=.1, title = 'do nothing')
11
---> 12 show(slider)
11 frames
/usr/local/lib/python3.6/dist-packages/tornado/gen.py in <module>()
79 import types
80
---> 81 from tornado.concurrent import (
82 Future,
83 is_future,
ImportError: cannot import name 'future_set_exc_info'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
I do have bokeh package installed as well. Not sure what the issue is. Any help is appreciated.
In order to fix the error above, the tornado package must be up to date. To see what version works, simply look up the package itself to see what is the current version. Then input the following code at the beginning of your program to update the package.
# update tornado package
!pip install tornado==6.0.4
import tornado

Python parallel programming “No traceback available"

I am trying to run parallel code in python utilizing ipyparallel package.
import ipyparallel as ipp
# create client & view
rc = ipp.Client()
dv = rc[:]
v = rc.load_balanced_view()
def my(i):
import numpy as np
aa[:,:,i]=np.dot(uanom_L[:,:,i-I_a:i+I_a+1],lcoz_a)
bb[:,:,i]=np.dot(uanom_L[:,:,i-I_b:i+I_b+1],lcoz_b)
print(i)
return aa,bb
aaa=v.map(my,np.arange(I_a,c-I_a))
aaa.get()
Yet, I got the following error,
[3:apply]: No traceback available
[2:apply]: No traceback available
[1:apply]: No traceback available
[0:apply]: No traceback available
8773 more exceptions ...
Any ideas
Thanks

AttributeError: 'module' object has no attribute 'version' Canopy

Hi I am going to preface this with I could just be really dumb so don't overlook that, but suddenly when opening canopy today I wasn't able to run one of my typical scripts with the error AttributeError: 'module' object has no attribute ' version' when trying to load pandas. From what I can gather it seems when bumpy is called through pandas it fails. I checked my working directory for files named numpy.py to see if I idiotically named a file numpy but failed to find such a file. I also attempted to uninstall and reinstall both numpy and pandas from the package manager in canopy. Any suggestions?
%run "/Users/jim/Documents/ORAL-PAT-2.5-3.5plotly.py"
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/jim/Documents/ORAL-PAT-2.5-3.5plotly.py in <module>()
1 #import the modules you need
----> 2 import pandas as pd
3 import numpy as np
4 import plotly.plotly as py
5 import plotly.tools as tls
/Users/jim/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/__init__.py in <module>()
20
21 # numpy compat
---> 22 from pandas.compat.numpy_compat import *
23
24 try:
/Users/jim/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/compat/numpy_compat.py in <module>()
13
14 # numpy versioning
---> 15 _np_version = np.version.short_version
16 _np_version_under1p8 = LooseVersion(_np_version) < '1.8'
17 _np_version_under1p9 = LooseVersion(_np_version) < '1.9'
AttributeError: 'module' object has no attribute 'version'
Just had the same problem after downgrading Pandas and upgrading again to fix another issue. This is just a hack, but you could try this:
Open ...pandas/compat/numpy_compat.py and replace np.version.short_version with np._np_version
Hope that helps!

Categories

Resources