2

Does unirest support python3? I have googled and zero information comes up. Even in the unirest documentation it does not say it is 2.x only which leads me to believe it supports both 3.x and 2.x. However the install fails with 3.4 and succeeds with 2.7. See below.

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

For now I am using 2.7 but I prefer to use 3.x for new projects.

Nicholas Kolatsis
  • 427
  • 1
  • 5
  • 9

1 Answers1

7

The project is not Python 3 compatible. When the project doesn't explicitly state this (not in the setup.py trove classifiers nor in documentation), you'll have to look at the source code.

There I find:

The project depends on the poster library, which is also urllib2 specific.

I'd use the requests library instead. It supports Python 3 out of the box, and apart from asynchronous requests it supports the same feature set (but better as it doesn't have the shortcomings urllib2 brings along). For asynchronous requests, you can add on requests-futures.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Thanks. It is a bit crazy to me that mashape releases a relatively new library and it is python2 only. I think I'm just going to use the requests library and skip this. – Nicholas Kolatsis Jan 31 '15 at 13:45
  • 1
    Most of the features purported by that library are also available in the [`requests` project](http://python-requests.org); the async part is implemented with a thread, `requests` has [better options](http://stackoverflow.com/questions/9110593/asynchronous-requests-with-python-requests) for async work. `requests` works great on Python 3. – Martijn Pieters Jan 31 '15 at 13:49