本人环境Mac OS + pyenv + Python3.6.2
遇到问题的安装命令:
pip install google-cloud-translate
报错如下:
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting google-cloud-translate
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9b/77/7007bf1ee38c98337cbf4e6cf5f619fb12b384cf7fb9503f4021911a7547/google_cloud_translate-1.3.3-py2.py3-none-any.whl
Collecting google-api-core<2.0.0dev,>=1.6.0 (from google-cloud-translate)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/7d/73/e4877e921fe59307ec6b1b0b0c2ad9fde2d1c6bab8dd06ec913891a20dc6/google_api_core-1.8.2-py2.py3-none-any.whl
Collecting google-cloud-core<0.30dev,>=0.29.0 (from google-cloud-translate)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/0c/f2/3c225e7a69cb27d283b68bff867722bd066bc1858611180197f711815ea5/google_cloud_core-0.29.1-py2.py3-none-any.whl
Requirement already satisfied: requests<3.0.0dev,>=2.18.0 in /Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.6.0->google-cloud-translate) (2.18.4)
Requirement already satisfied: six>=1.10.0 in /Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.6.0->google-cloud-translate) (1.10.0)
Collecting google-auth<2.0dev,>=0.4.0 (from google-api-core<2.0.0dev,>=1.6.0->google-cloud-translate)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c5/9b/ed0516cc1f7609fb0217e3057ff4f0f9f3e3ce79a369c6af4a6c5ca25664/google_auth-1.6.3-py2.py3-none-any.whl
Requirement already satisfied: pytz in /Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.6.0->google-cloud-translate) (2017.3)
Collecting setuptools>=34.0.0 (from google-api-core<2.0.0dev,>=1.6.0->google-cloud-translate)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d1/6a/4b2fcefd2ea0868810e92d519dacac1ddc64a2e53ba9e3422c3b62b378a6/setuptools-40.8.0-py2.py3-none-any.whl
Collecting googleapis-common-protos!=1.5.4,<2.0dev,>=1.5.3 (from google-api-core<2.0.0dev,>=1.6.0->google-cloud-translate)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/76/a6/903a1c1c1fd676660174a9be4ec777c9b547392f640b16a326182b8fe484/googleapis-common-protos-1.5.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/setuptools/__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, filterfalse, map
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/setuptools/extern/__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3017, in <module>
@_call_aside
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3003, in _call_aside
f(*args, **kwargs)
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3045, in _initialize_master_working_set
dist.activate(replace=False)
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2577, in activate
declare_namespace(pkg)
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2151, in declare_namespace
_handle_ns(packageName, path_item)
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2091, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/Users/vien/.pyenv/versions/3.6.2/envs/py3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2120, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/1c/3jlsrzg16hj2p4x9nxkdwwbw0000gn/T/pip-install-_shivf0v/googleapis-common-protos/
这是因为setuptools
过期了,我们需要升级一下:
pip install --upgrade setuptools
至此便可以了,重新执行上面的安装命令即可。
viencoding.com版权所有,允许转载,但转载请注明出处和原文链接: https://viencoding.com/article/135