2

unirest 支持 python3 吗?我用谷歌搜索了零信息。即使在最统一的文档中,它也没有说它只是 2.x,这让我相信它同时支持 3.x 和 2.x。但是安装失败并使用 3.4 并成功使用 2.7。见下文。

nkltss:~/dev$ mkvirtualenv mashape -p /usr/bin/python3
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in mashape/bin/python3
Also creating executable in mashape/bin/python
Installing setuptools, pip...done.


(mashape)nkltss:~/dev$ pip install unirest
Downloading/unpacking unirest
  Downloading Unirest-1.1.6.tar.gz
  Running setup.py (path:/home/nick/.virtualenvs/mashape/build/unirest/setup.py) egg_info for package unirest

    warning: no files found matching '*.txt' under directory 'docs'
Downloading/unpacking poster>=0.8.1 (from unirest)
  Downloading poster-0.8.1.tar.gz
  Running setup.py (path:/home/nick/.virtualenvs/mashape/build/poster/setup.py) egg_info for package poster
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/home/nick/.virtualenvs/mashape/build/poster/setup.py", line 2, in <module>
        import poster
      File "/home/nick/.virtualenvs/mashape/build/poster/poster/__init__.py", line 29, in <module>
        import poster.streaminghttp
      File "/home/nick/.virtualenvs/mashape/build/poster/poster/streaminghttp.py", line 61
        print "send:", repr(value)
                    ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/home/nick/.virtualenvs/mashape/build/poster/setup.py", line 2, in <module>

    import poster

  File "/home/nick/.virtualenvs/mashape/build/poster/poster/__init__.py", line 29, in <module>

    import poster.streaminghttp

  File "/home/nick/.virtualenvs/mashape/build/poster/poster/streaminghttp.py", line 61

    print "send:", repr(value)

                ^

SyntaxError: invalid syntax

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/nick/.virtualenvs/mashape/build/poster
Storing debug log for failure in /home/nick/.pip/pip.log

目前我使用的是 2.7,但我更喜欢将 3.x 用于新项目。

4

1 回答 1

6

该项目不兼容 Python 3。如果项目没有明确说明这一点(不在setup.pytrove 分类器或文档中),您将不得不查看源代码

在那里我发现:

该项目依赖于poster,这也是urllib2特定的。

我会改用requests图书馆。它开箱即用地支持 Python 3,除了异步请求之外,它还支持相同的功能集(但更好,因为它没有带来的缺点urllib2)。对于异步请求,您可以添加requests-futures.

于 2015-01-31T12:06:36.150 回答