使用Google Cloud Speech的ModuleNotFoundError

时间:2018-01-30 05:51:41

标签: python pip google-cloud-platform google-cloud-speech

编辑:

我使用以下命令安装 Google Cloud Speech

pip install --upgrade google-cloud-speech

当我使用 Python3 运行 Python程序音频转换为文字时,我收到错误消息:< / p>

Traceback (most recent call last):
  File "/home/prateek/Google Drive/projects/linuxAI/src/linuxAI.py", line 2, in <module>
    from google.cloud import speech
  File "/usr/lib/python3.6/site-packages/google/cloud/speech/__init__.py", line 22, in <module>
    from google.cloud.speech.client import Client
  File "/usr/lib/python3.6/site-packages/google/cloud/speech/client.py", line 22, in <module>
    from google.cloud.client import Client as BaseClient
ModuleNotFoundError: No module named 'google.cloud.client'

但如果我使用 Python(Python2)运行相同的程序,我会得到正确的输出。 我想使用 Python3 运行程序。我正在使用 OpenSuse Tumblebeed。

所以,我尝试了以下命令来安装 google-cloud

sudo pip install --upgrade google-cloud
sudo pip3 install --upgrade google-cloud
sudo pip3.6 install --upgrade google-cloud

但是我通过所有这些命令得到以下错误:

Requirement already satisfied: google-cloud in /usr/lib/python3.6/si
te-packages/google_cloud-0.32.1.dev1-py3.6.egg
Requirement already satisfied: google-api-core<0.2.0dev,>=0.1.2 in /
usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-bigquery<0.29dev,>=0.28.
0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-bigquery-datatransfer<0.
2dev,>=0.1.0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-bigtable<0.29dev,>=0.28.
1 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-container<0.2dev,>=0.1.0
 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-core<0.29dev,>=0.28.0 in
 /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-datastore<1.5dev,>=1.4.0
 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-dns<0.29dev,>=0.28.0 in 
/usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-error-reporting<0.29dev,
>=0.28.0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-firestore<0.29dev,>=0.28
.0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-language<1.1dev,>=1.0.0 
in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-logging<1.5dev,>=1.4.0 i
n /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-monitoring<0.29dev,>=0.2
8.0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-pubsub<0.31dev,>=0.30.0 
in /usr/lib/python3.6/site-packages/google_cloud_pubsub-0.30.1-py3.6
.egg (from google-cloud)
Requirement already satisfied: google-cloud-resource-manager<0.29dev
,>=0.28.0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-runtimeconfig<0.29dev,>=
0.28.0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-spanner<0.30dev,>=0.29.0
 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-speech<0.31dev,>=0.30.0 
in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-storage<1.7dev,>=1.6.0 i
n /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-trace<0.18dev,>=0.17.0 i
n /usr/lib/python3.6/site-packages/google_cloud_trace-0.17.0-py3.6.e
gg (from google-cloud)
Requirement already satisfied: google-cloud-translate<1.4dev,>=1.3.0
 in /usr/lib/python3.6/site-packages/google_cloud_translate-1.3.0-py
3.6.egg (from google-cloud)
Requirement already satisfied: google-cloud-videointelligence<1.1dev
,>=1.0.0 in /usr/lib/python3.6/site-packages (from google-cloud)
Requirement already satisfied: google-cloud-vision<0.30dev,>=0.29.0 
in /usr/lib/python3.6/site-packages/google_cloud_vision-0.29.0-py3.6
.egg (from google-cloud)
Requirement already satisfied: google-auth<2.0.0dev,>=0.4.0 in /usr/
lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.2->
google-cloud)
Requirement already satisfied: pytz in /usr/lib/python3.6/site-packa
ges (from google-api-core<0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: googleapis-common-protos<2.0dev,>=1.5
.3 in /usr/lib/python3.6/site-packages (from google-api-core<0.2.0de
v,>=0.1.2->google-cloud)
Requirement already satisfied: requests<3.0.0dev,>=2.18.0 in /usr/li
b/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.2->go
ogle-cloud)
Requirement already satisfied: protobuf>=3.0.0 in /usr/lib64/python3
.6/site-packages (from google-api-core<0.2.0dev,>=0.1.2->google-clou
d)
Requirement already satisfied: six>=1.10.0 in /usr/lib/python3.6/sit
e-packages (from google-api-core<0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: setuptools>=34.0.0 in /usr/lib/python
3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.2->google-clo
ud)
Requirement already satisfied: google-resumable-media>=0.2.1 in /usr
/lib/python3.6/site-packages (from google-cloud-bigquery<0.29dev,>=0
.28.0->google-cloud)
Requirement already satisfied: google-gax<0.16dev,>=0.15.7 in /usr/l
ib/python3.6/site-packages (from google-cloud-bigtable<0.29dev,>=0.2
8.1->google-cloud)
Requirement already satisfied: gapic-google-cloud-datastore-v1<0.16d
ev,>=0.15.0 in /usr/lib/python3.6/site-packages (from google-cloud-d
atastore<1.5dev,>=1.4.0->google-cloud)
Requirement already satisfied: gapic-google-cloud-error-reporting-v1
beta1<0.16dev,>=0.15.0 in /usr/lib/python3.6/site-packages (from goo
gle-cloud-error-reporting<0.29dev,>=0.28.0->google-cloud)
Requirement already satisfied: gapic-google-cloud-logging-v2<0.92dev
,>=0.91.0 in /usr/lib/python3.6/site-packages (from google-cloud-log
ging<1.5dev,>=1.4.0->google-cloud)
Requirement already satisfied: grpc-google-iam-v1<0.12dev,>=0.11.1 i
n /usr/lib/python3.6/site-packages (from google-cloud-pubsub<0.31dev
,>=0.30.0->google-cloud)
Collecting psutil<6.0dev,>=5.2.2 (from google-cloud-pubsub<0.31dev,>
=0.30.0->google-cloud)
  Using cached psutil-5.4.3.tar.gz
Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/lib/pyt
hon3.6/site-packages (from google-auth<2.0.0dev,>=0.4.0->google-api-
core<0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: cachetools>=2.0.0 in /usr/lib/python3
.6/site-packages (from google-auth<2.0.0dev,>=0.4.0->google-api-core
<0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: rsa>=3.1.4 in /usr/lib/python3.6/site
-packages (from google-auth<2.0.0dev,>=0.4.0->google-api-core<0.2.0d
ev,>=0.1.2->google-cloud)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/lib/pyt
hon3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-co
re<0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python
3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core<
0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/lib/python3.6/
site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core<0.2.
0dev,>=0.1.2->google-cloud)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/pyt
hon3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-co
re<0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: dill<0.3dev,>=0.2.5 in /usr/lib/pytho
n3.6/site-packages (from google-gax<0.16dev,>=0.15.7->google-cloud-b
igtable<0.29dev,>=0.28.1->google-cloud)
Requirement already satisfied: future<0.17dev,>=0.16.0 in /usr/lib/p
ython3.6/site-packages (from google-gax<0.16dev,>=0.15.7->google-clo
ud-bigtable<0.29dev,>=0.28.1->google-cloud)
Requirement already satisfied: ply==3.8 in /usr/lib/python3.6/site-p
ackages (from google-gax<0.16dev,>=0.15.7->google-cloud-bigtable<0.2
9dev,>=0.28.1->google-cloud)
Requirement already satisfied: grpcio<2.0dev,>=1.0.2 in /usr/lib64/p
ython3.6/site-packages (from google-gax<0.16dev,>=0.15.7->google-clo
ud-bigtable<0.29dev,>=0.28.1->google-cloud)
Requirement already satisfied: oauth2client<4.0dev,>=2.0.0 in /usr/l
ib/python3.6/site-packages (from gapic-google-cloud-datastore-v1<0.1
6dev,>=0.15.0->google-cloud-datastore<1.5dev,>=1.4.0->google-cloud)
Requirement already satisfied: proto-google-cloud-datastore-v1[grpc]
<0.91dev,>=0.90.3 in /usr/lib/python3.6/site-packages (from gapic-go
ogle-cloud-datastore-v1<0.16dev,>=0.15.0->google-cloud-datastore<1.5
dev,>=1.4.0->google-cloud)
Requirement already satisfied: proto-google-cloud-error-reporting-v1
beta1[grpc]<0.16dev,>=0.15.3 in /usr/lib/python3.6/site-packages (fr
om gapic-google-cloud-error-reporting-v1beta1<0.16dev,>=0.15.0->goog
le-cloud-error-reporting<0.29dev,>=0.28.0->google-cloud)
Requirement already satisfied: proto-google-cloud-logging-v2[grpc]<0
.92dev,>=0.91.3 in /usr/lib/python3.6/site-packages (from gapic-goog
le-cloud-logging-v2<0.92dev,>=0.91.0->google-cloud-logging<1.5dev,>=
1.4.0->google-cloud)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.1 in /usr/lib/pyth
on3.6/site-packages (from pyasn1-modules>=0.2.1->google-auth<2.0.0de
v,>=0.4.0->google-api-core<0.2.0dev,>=0.1.2->google-cloud)
Requirement already satisfied: httplib2>=0.9.1 in /usr/lib/python3.6
/site-packages (from oauth2client<4.0dev,>=2.0.0->gapic-google-cloud
-datastore-v1<0.16dev,>=0.15.0->google-cloud-datastore<1.5dev,>=1.4.
0->google-cloud)
Installing collected packages: psutil
  Running setup.py install for psutil ... error
    Complete output from command /usr/bin/python3 -u -c "import setu
ptools, tokenize;__file__='/tmp/pip-build-1mt8_94q/psutil/setup.py';
f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\
r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
 --record /tmp/pip-co20my3o-record/install-record.txt --single-versi
on-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/psutil
    copying psutil/_exceptions.py -> build/lib.linux-x86_64-3.6/psut
il
    copying psutil/_psposix.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psaix.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_common.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/__init__.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_compat.py -> build/lib.linux-x86_64-3.6/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.6/psuti
l
    creating build/lib.linux-x86_64-3.6/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.linux-x86_64-3.6/p
sutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.6/p
sutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64
-3.6/psutil/tests
    copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-3.6/p
sutil/tests
    copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86
_64-3.6/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.linux-x86_
64-3.6/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.
6/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.6
/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.6/
psutil/tests
    copying psutil/tests/__init__.py -> build/lib.linux-x86_64-3.6/p
sutil/tests
    copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.6/p
sutil/tests
    copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3
.6/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3
.6/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.6
/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.6
/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-3
.6/psutil/tests
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/psutil
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -fmessag
e-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fsta
ck-protector-strong -funwind-tables -fasynchronous-unwind-tables -g 
-DOPENSSL_LOAD_CONF -fmessage-length=0 -grecord-gcc-switches -O2 -Wa
ll -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fas
ynchronous-unwind-tables -g -fmessage-length=0 -grecord-gcc-switches
 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tab
les -fasynchronous-unwind-tables -g -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_
VERSION=543 -DPSUTIL_LINUX=1 -I/usr/include/python3.6m -c psutil/_ps
util_common.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_common.o
    psutil/_psutil_common.c:9:10: fatal error: Python.h: No such fil
e or directory
     #include <Python.h>
              ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file_
_='/tmp/pip-build-1mt8_94q/psutil/setup.py';f=getattr(tokenize, 'ope
n', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();ex
ec(compile(code, __file__, 'exec'))" install --record /tmp/pip-co20m
y3o-record/install-record.txt --single-version-externally-managed --
compile" failed with error code 1 in /tmp/pip-build-1mt8_94q/psutil/

我认为 GCC 正在尝试查找 python.h ,因此进程正在退出,错误代码为1。

1 个答案:

答案 0 :(得分:0)

我对OpenSuse并不熟悉,但正如你所描述的那样,我认为python3无法找到google-cloud-speech软件包,因为&#34; pip&#34;只会让你的python2二进制文件可用。解决方案(在debian上)应该包括:

  1. 安装pip3(如果你还没有):
  2. sudo apt-get install python3-pip
    1. 使用pip3安装Google Cloud Speech
    2. sudo pip3 install --upgrade google-cloud-speech