The env is macOS 10.14.2 with python 3.7.
The google-cloud-vision is already installed:
Avivs-MacBook-Pro:Project Aviv$ pip3 show google-cloud-vision
Name: google-cloud-vision
Version: 0.35.2
Summary: Cloud Vision API API client library
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google LLC
Author-email: [email protected]
License: Apache 2.0
Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Requires: google-api-core
Required-by:
Avivs-MacBook-Pro:Project Aviv$ python3 -c "from google.cloud import vision; print(vision.__name__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/vision.py", line 17, in <module>
from google.cloud.vision_v1 import ImageAnnotatorClient
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/vision_v1/__init__.py", line 19, in <module>
from google.cloud.vision_helpers.decorators import add_single_feature_methods
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/vision_helpers/__init__.py", line 18, in <module>
from google.api_core import protobuf_helpers as protobuf
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/__init__.py", line 20, in <module>
from pkg_resources import get_distribution
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3126, in <module>
@_call_aside
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3110, in _call_aside
f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3154, in _initialize_master_working_set
for dist in working_set
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3154, in <genexpr>
for dist in working_set
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2661, in activate
declare_namespace(pkg)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2187, in declare_namespace
_handle_ns(packageName, path_item)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2120, in _handle_ns
loader.load_module(packageName)
File "./google.py", line 6, in <module>
from google.cloud.vision import types
ImportError: cannot import name 'types' from 'google.cloud.vision' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/vision.py)
The same problem when I'm running it from virtualenv.
@avivco94 I just tried in a clean venv without any issue. Is it possible your venv was contaminated by a previous install?
mkdir test
cd test
python3 -m venv venv
source venv/bin/activate
pip install google-cloud-vision
python3 -c "from google.cloud import vision; print(vision.__name__)"
google.cloud.vision
@avivco94 I just tried in a clean venv without any issue. Is it possible your venv was contaminated by a previous install?
mkdir test cd test python3 -m venv venv source venv/bin/activate pip install google-cloud-vision python3 -c "from google.cloud import vision; print(vision.__name__)" google.cloud.vision
It's not working... (the same issue)
@avivco94 Can you please report the libraries installed in your environment (e.g., via pip freeze).
@avivco94 Can you please report the libraries installed in your environment (e.g., via
pip freeze).
Avivs-MacBook-Pro:test Aviv$ source venv/bin/activate
(venv) Avivs-MacBook-Pro:test Aviv$ pip freeze
cachetools==3.0.0
certifi==2018.11.29
chardet==3.0.4
google-api-core==1.7.0
google-auth==1.6.2
google-cloud-vision==0.35.2
googleapis-common-protos==1.5.5
grpcio==1.17.1
idna==2.8
protobuf==3.6.1
pyasn1==0.4.5
pyasn1-modules==0.2.3
pytz==2018.7
requests==2.21.0
rsa==4.0
six==1.12.0
urllib3==1.24.1
Trying to reproduce:
$ python3.7 -m venv /tmp/gcp/7045
$ /tmp/gcp/7045/bin/pip install --upgrade setuptools pip
Looking in links: file:///home/tseaver/.pip/wheels
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl
Collecting pip
Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
Found existing installation: setuptools 39.0.1
Uninstalling setuptools-39.0.1:
Successfully uninstalled setuptools-39.0.1
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1 setuptools-40.6.3
$ /tmp/gcp/7045/bin/pip install google-cloud-vision
...
Successfully installed cachetools-3.0.0 certifi-2018.11.29 chardet-3.0.4 google-api-core-1.7.0 google-auth-1.6.2 google-cloud-vision-0.35.2 googleapis-common-protos-1.5.5 grpcio-1.17.1 idna-2.8 protobuf-3.6.1 pyasn1-0.4.5 pyasn1-modules-0.2.3 pytz-2018.9 requests-2.21.0 rsa-4.0 six-1.12.0 urllib3-1.24.1
$ /tmp/gcp/7045/bin/python -c "from google.cloud import vision; print(vision.__name__)"
google.cloud.vision
Looking at the packages installed in my virtualenv:
$ /tmp/gcp/7045/bin/pip freeze
-f file:///XXX/.pip/wheels
cachetools==3.0.0
certifi==2018.11.29
chardet==3.0.4
google-api-core==1.7.0
google-auth==1.6.2
google-cloud-vision==0.35.2
googleapis-common-protos==1.5.5
grpcio==1.17.1
idna==2.8
protobuf==3.6.1
pyasn1==0.4.5
pyasn1-modules==0.2.3
pytz==2018.9
requests==2.21.0
rsa==4.0
six==1.12.0
urllib3==1.24.1
I can't see anything different, except the trivial pytz update.
Trying to reproduce:
$ python3.7 -m venv /tmp/gcp/7045 $ /tmp/gcp/7045/bin/pip install --upgrade setuptools pip Looking in links: file:///home/tseaver/.pip/wheels Collecting setuptools Using cached https://files.pythonhosted.org/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl Collecting pip Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl Installing collected packages: setuptools, pip Found existing installation: setuptools 39.0.1 Uninstalling setuptools-39.0.1: Successfully uninstalled setuptools-39.0.1 Found existing installation: pip 10.0.1 Uninstalling pip-10.0.1: Successfully uninstalled pip-10.0.1 Successfully installed pip-18.1 setuptools-40.6.3 $ /tmp/gcp/7045/bin/pip install google-cloud-vision ... Successfully installed cachetools-3.0.0 certifi-2018.11.29 chardet-3.0.4 google-api-core-1.7.0 google-auth-1.6.2 google-cloud-vision-0.35.2 googleapis-common-protos-1.5.5 grpcio-1.17.1 idna-2.8 protobuf-3.6.1 pyasn1-0.4.5 pyasn1-modules-0.2.3 pytz-2018.9 requests-2.21.0 rsa-4.0 six-1.12.0 urllib3-1.24.1 $ /tmp/gcp/7045/bin/python -c "from google.cloud import vision; print(vision.__name__)" google.cloud.visionLooking at the packages installed in my virtualenv:
$ /tmp/gcp/7045/bin/pip freeze -f file:///XXX/.pip/wheels cachetools==3.0.0 certifi==2018.11.29 chardet==3.0.4 google-api-core==1.7.0 google-auth==1.6.2 google-cloud-vision==0.35.2 googleapis-common-protos==1.5.5 grpcio==1.17.1 idna==2.8 protobuf==3.6.1 pyasn1==0.4.5 pyasn1-modules==0.2.3 pytz==2018.9 requests==2.21.0 rsa==4.0 six==1.12.0 urllib3==1.24.1I can't see anything different, except the trivial
pytzupdate.
It works now, thanks.
Glad it is resolved.
Found what was the problem, I've created a file named google.py from where I was execute the code and the Google API used it.
Most helpful comment
Found what was the problem, I've created a file named google.py from where I was execute the code and the Google API used it.