I am trying to import the module tensorflow_quantum as follows
>>> import tensorflow_quantum as tfq
But, I get the following error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.8/site-packages/tensorflow_quantum/__init__.py", line 18, in <module>
from tensorflow_quantum.core import (append_circuit, get_expectation_op,
File "/opt/conda/lib/python3.8/site-packages/tensorflow_quantum/core/__init__.py", line 17, in <module>
from tensorflow_quantum.core.ops import (get_expectation_op,
File "/opt/conda/lib/python3.8/site-packages/tensorflow_quantum/core/ops/__init__.py", line 18, in <module>
from tensorflow_quantum.core.ops.circuit_execution_ops import (
File "/opt/conda/lib/python3.8/site-packages/tensorflow_quantum/core/ops/circuit_execution_ops.py", line 20, in <module>
from tensorflow_quantum.core.ops import (cirq_ops, tfq_simulate_ops,
File "/opt/conda/lib/python3.8/site-packages/tensorflow_quantum/core/ops/cirq_ops.py", line 22, in <module>
import cirq_google
File "/opt/conda/lib/python3.8/site-packages/cirq_google/__init__.py", line 18, in <module>
from cirq import _compat
ImportError: cannot import name '_compat' from 'cirq' (unknown location)
I have already installed cirq. It works as follows
>>> import cirq
>>>
Any help please?
Related
I'm getting this error while running my python script on a Linux virtual machine.
Traceback (most recent call last): File "model.py",
line 7, in <module> from data_load import * File "/home/oshanjayawardanav100/biometrics-self-supervised/supervised_ucihar/data_load.py",
line 2, in <module> from sklearn.preprocessing import StandardScaler File "/opt/conda/lib/python3.7/site-packages/sklearn/__init__.py",
line 82, in <module> from .base import clone File "/opt/conda/lib/python3.7/site-packages/sklearn/base.py",
line 17, in <module> from .utils import _IS_32BIT File "/opt/conda/lib/python3.7/site-packages/sklearn/utils/__init__.py",
line 28, in <module> from .fixes import np_version, parse_version File "/opt/conda/lib/python3.7/site-packages/sklearn/utils/fixes.py",
line 20, in <module> import scipy.stats File "/opt/conda/lib/python3.7/site-packages/scipy/stats/__init__.py",
line 441, in <module> from .stats import * File "/opt/conda/lib/python3.7/site-packages/scipy/stats/stats.py",
line 43, in <module> from . import distributions File "/opt/conda/lib/python3.7/site-packages/scipy/stats/distributions.py",
line 8, in <module> from ._distn_infrastructure import (rv_discrete, rv_continuous, rv_frozen) File "/opt/conda/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py",
line 24, in <module> from scipy import optimize File "/opt/conda/lib/python3.7/site-packages/scipy/optimize/__init__.py",
line 400, in <module> from .optimize import * File "/opt/conda/lib/python3.7/site-packages/scipy/optimize/optimize.py",
line 36, in <module> from ._numdiff import approx_derivative File "/opt/conda/lib/python3.7/site-packages/scipy/optimize/_numdiff.py",
line 8, in <module> from ._group_columns import group_dense, group_sparse
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.26' not found (required by /opt/conda/lib/python3.7/site-packages/scipy/optimize/_group_columns.cpython-37m-x86_64-linux-gnu.so)`
I have no idea why I'm getting this.
I already tried this https://stackoverflow.com/a/55899959/15938633
But it is not working
I'm having this weird problem in running torchvision in macOS Catalina. Here's the traceback
Traceback (most recent call last):
File "/Users/xdriyad/PycharmProjects/Resnet/main.py", line 1, in <module>
from model import ResNet50
File "/Users/xdriyad/PycharmProjects/Resnet/model.py", line 1, in <module>
import torch
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/__init__.py", line 573, in <module>
import torch.quantization
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/__init__.py", line 9, in <module>
from .quantize_fx import *
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/quantize_fx.py", line 1, in <module>
from .fx import Fuser # noqa: F401
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/fx/__init__.py", line 1, in <module>
from .quantize import Quantizer
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/fx/quantize.py", line 2, in <module>
from torch._fx import (
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/__init__.py", line 89, in <module>
from .symbolic_trace import symbolic_trace, Tracer
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/symbolic_trace.py", line 9, in <module>
from .proxy import Proxy, _create_proxy, TracerBase
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/proxy.py", line 7, in <module>
from typing import Tuple, Dict, Optional, Iterable, NoReturn, Any, Union, Callable
ImportError: cannot import name 'NoReturn'
import seaborn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\HP\Anaconda3\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\HP\Anaconda3\lib\site-packages\seaborn\rcmod.py", line 5, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\HP\Anaconda3\lib\site-packages\seaborn\palettes.py", line 12, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\HP\Anaconda3\lib\site-packages\seaborn\utils.py", line 7, in <module>
from scipy import stats
File "C:\Users\HP\Anaconda3\lib\site-packages\scipy\stats\__init__.py", line 345, in <module>
from .morestats import *
File "C:\Users\HP\Anaconda3\lib\site-packages\scipy\stats\morestats.py", line 12, in <module>
from numpy.testing.decorators import setastest
ModuleNotFoundError: No module named 'numpy.testing.decorators'
Welcome to Stackoverflow and Happy New Year!
I think you haven't installed numpy.testing.decorators.
Run pip install numpy and retry.
I was executing a code from the book Think Python in Python 3. The code follows.
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import urllib.request
conn = urllib.request.urlopen('http://thinkpython.com/secret.html')
for line in conn:
print(line.strip())
When I execute this code in my machine's terminal, I got this following output.
Traceback (most recent call last):
File "secret.py", line 4, in <module>
import urllib.request
File "/usr/lib/python3.6/urllib/request.py", line 84, in <module>
import base64
File "/usr/lib/python3.6/base64.py", line 10, in <module>
import struct
File "/usr/lib/python3.6/struct.py", line 13, in <module>
from _struct import *
ModuleNotFoundError: No module named '_struct'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, re, pwd, grp, os, time
File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
Original exception was:
Traceback (most recent call last):
File "secret.py", line 4, in <module>
import urllib.request
File "/usr/lib/python3.6/urllib/request.py", line 84, in <module>
import base64
File "/usr/lib/python3.6/base64.py", line 10, in <module>
import struct
File "/usr/lib/python3.6/struct.py", line 13, in <module>
from _struct import *
ModuleNotFoundError: No module named '_struct'
I did this same code in Anaconda, and I got the correct output. Can anybody help me with this problem.
Every time I try to install any package using pip3 this error comes.
And when I open python3 in terminal and try to import string module the same error comes. I am not able to figure out any solution for it. My OS version is Ubuntu 16.04.
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 5, in <module>
import logging
File "/usr/lib/python3.5/logging/__init__.py", line 28, in <module>
from string import Template
ImportError: No module named 'string'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
from urllib.request import urlopen
File "/usr/lib/python3.5/urllib/request.py", line 88, in <module>
import http.client
File "/usr/lib/python3.5/http/client.py", line 71, in <module>
import email.parser
File "/usr/lib/python3.5/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.5/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.5/email/message.py", line 16, in <module>
from email import utils
File "/usr/lib/python3.5/email/utils.py", line 40, in <module>
from email.charset import Charset
File "/usr/lib/python3.5/email/charset.py", line 15, in <module>
import email.quoprimime
File "/usr/lib/python3.5/email/quoprimime.py", line 44, in <module>
from string import ascii_letters, digits, hexdigits
ImportError: No module named 'string'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 5, in <module>
import logging
File "/usr/lib/python3.5/logging/__init__.py", line 28, in <module>
from string import Template
ImportError: No module named 'string'
The problem solved since my python 3.5 directory was missing string.py file.