繁体   English   中英

无法在python3中安装protobuf

[英]Failed to install protobuf in python3

当我尝试使用python3安装protobuf时,我输入以下命令

➜  python setup.py build

并获取此烦人的错误消息。

Download error on http://code.google.com/p/google-apputils-python: timed out -- Some packages may not be found!

  File "build/bdist.linux-x86_64/egg/google/apputils/app.py", line 95

print 'Try --helpfull to get a list of all flags.'
                                                 ^
SyntaxError: Missing parentheses in call to 'print'

  File "build/bdist.linux-x86_64/egg/google/apputils/basetest.py", line 1063
    0600)


      ^
SyntaxError: invalid token

  File "build/bdist.linux-x86_64/egg/google/apputils/file_util.py", line 45
    def Write(filename, contents, overwrite_existing=True, mode=0666, gid=None):
                                                                   ^
SyntaxError: invalid token

  File "build/bdist.linux-x86_64/egg/google/apputils/appcommands.py", line 299
    except app.UsageError, error:
                         ^
SyntaxError: invalid syntax

  File "build/bdist.linux-x86_64/egg/google/apputils/run_script_module.py", line 122
    print 'Stub script %s (auto-generated). Options:' % sys.argv[0]
                                                    ^
SyntaxError: invalid syntax

zip_safe flag not set; analyzing archive contents...
google.__pycache__.__init__.cpython-34: module references __path__
google.apputils.__pycache__.__init__.cpython-34: module references __path__
google.apputils.__pycache__.setup_command.cpython-34: module references __file__
  File "/home/sptzxb/Downloads/protobuf-2.6.1/python/.eggs/google_apputils-0.4.2-py3.4.egg/google/apputils/app.py", line 95
    print 'Try --helpfull to get a list of all flags.'
                                                     ^
SyntaxError: Missing parentheses in call to 'print'

  File "/home/sptzxb/Downloads/protobuf-2.6.1/python/.eggs/google_apputils-0.4.2-py3.4.egg/google/apputils/basetest.py", line 1063
    0600)
       ^
SyntaxError: invalid token

  File "/home/sptzxb/Downloads/protobuf-2.6.1/python/.eggs/google_apputils-0.4.2-py3.4.egg/google/apputils/file_util.py", line 45
    def Write(filename, contents, overwrite_existing=True, mode=0666, gid=None):
                                                                   ^
SyntaxError: invalid token

  File "/home/sptzxb/Downloads/protobuf-2.6.1/python/.eggs/google_apputils-0.4.2-py3.4.egg/google/apputils/appcommands.py", line 299
    except app.UsageError, error:
                         ^
SyntaxError: invalid syntax

  File "/home/sptzxb/Downloads/protobuf-2.6.1/python/.eggs/google_apputils-0.4.2-py3.4.egg/google/apputils/run_script_module.py", line 122
    print 'Stub script %s (auto-generated). Options:' % sys.argv[0]
                                                    ^
SyntaxError: invalid syntax


Installed /home/sptzxb/Downloads/protobuf-2.6.1/python/.eggs/google_apputils-0.4.2-py3.4.egg
Searching for python-gflags>=1.4
Reading https://pypi.python.org/simple/python-gflags/
Reading http://code.google.com/p/python-gflags
Traceback (most recent call last):
  File "setup.py", line 200, in <module>
    "Protocol Buffers are Google's data interchange format.",
  File "/usr/lib/python3.4/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 268, in __init__
    self.fetch_build_eggs(attrs['setup_requires'])
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 313, in fetch_build_eggs
    replace_conflicting=True,
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 836, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1081, in best_match
    return self.obtain(req, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1093, in obtain
    return installer(requirement)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 380, in fetch_build_egg
    return cmd.easy_install(req)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 649, in easy_install
    not self.always_copy, self.local_index
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 590, in fetch_distribution
    self.find_packages(requirement)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 427, in find_packages
    self.scan_url(self.index_url + requirement.unsafe_name+'/')
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 761, in scan_url
    self.process_url(url, True)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 325, in process_url
    page = self.process_index(url, page)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 404, in process_index
    self.scan_url(new_url)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 761, in scan_url
    self.process_url(url, True)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 304, in process_url
    f = self.open_url(url, "Download error on %s: %%s -- Some packages may not be found!" % url)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 700, in open_url
    return open_with_auth(url, self.opener)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 894, in _socket_timeout
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/setuptools/package_index.py", line 1007, in open_with_auth
    fp = opener(request)
  File "/usr/lib/python3.4/urllib/request.py", line 464, in open
    response = self._open(req, data)
  File "/usr/lib/python3.4/urllib/request.py", line 482, in _open
    '_open', req)
  File "/usr/lib/python3.4/urllib/request.py", line 442, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.4/urllib/request.py", line 1211, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.4/urllib/request.py", line 1186, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 348, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 374, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

那么这是否意味着protobuf还不支持python3? 我发现setup.py是用python2语法编写的。

我可以以某种方式在python3中使用protobuf模块吗?

您正在使用protobuf 2.6.1,该协议仅通过2to3转换支持Python 3。

您需要安装v3.0.0-beta-1版本才能获得Python 3支持。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM