Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

pip install error on py3k #738

Closed
clee704 opened this Issue · 7 comments

6 participants

@clee704

With Python 3.2.3 and pip 1.1, pip install requests installs Requests 0.13.3 printing scary words like SyntaxError although it seems to work fine after installation. The exact output is below. If further information is needed, please let me know.

$ pip-3.2 install requests
Downloading/unpacking requests
  Downloading requests-0.13.3.tar.gz (515Kb): 515Kb downloaded
  Running setup.py egg_info for package requests

    warning: no files found matching 'tests/*.'
Installing collected packages: requests
  Running setup.py install for requests

    warning: no files found matching 'tests/*.'
      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth2/draft25/__init__.py", line 15
        AUTH_HEADER = u'auth_header'
                                   ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth2/draft25/parameters.py", line 50
        params = [((u'response_type', response_type)),
                                   ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth2/draft25/tokens.py", line 22
        body=None, ext=u'', hash_algorithm=u'hmac-sha-1'):
                         ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth2/draft25/utils.py", line 18
        u'HTTP': u'80',
              ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth1/rfc5849/__init__.py", line 20
        SIGNATURE_HMAC = u"HMAC-SHA1"
                                    ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth1/rfc5849/parameters.py", line 60
        part = u'{0}="{1}"'.format(escaped_name, escaped_value)
                          ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth1/rfc5849/signature.py", line 76
        base_string += u'&'
                          ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/oauth1/rfc5849/utils.py", line 36
        is_oauth = lambda kv: kv[0].startswith(u"oauth_")
                                                       ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/oauthlib/common.py", line 22
        always_safe = (u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                                                   ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/langgreekmodel.py", line 215
        'keepEnglishLetter': constants.False,
                                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/constants.py", line 46
        False = __builtin__.False
                                ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/universaldetector.py", line 51
        self.done = constants.False
                                  ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/sbcsgroupprober.py", line 59
        logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, constants.False, hebrewProber)
                                                                                        ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/langcyrillicmodel.py", line 287
        'keepEnglishLetter': constants.False,
                                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/langthaimodel.py", line 198
        'keepEnglishLetter': constants.False,
                                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/langbulgarianmodel.py", line 218
        'keepEnglishLetter': constants.False,
                                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/chardistribution.py", line 48
        self._mDone = constants.False # If this flag is set to constants.True, detection is done and conclusion has been made
                                    ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/langhebrewmodel.py", line 199
        'keepEnglishLetter': constants.False,
                                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/charsetgroupprober.py", line 44
        prober.active = constants.True
                                     ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/sbcharsetprober.py", line 42
        def __init__(self, model, reversed=constants.False, nameProber=None):
                                                         ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/escprober.py", line 48
        codingSM.active = constants.True
                                       ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/jpcntx.py", line 132
        self._mDone = constants.False # If this flag is set to constants.True, detection is done and conclusion has been made
                                    ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.2/dist-packages/requests/packages/chardet/langhungarianmodel.py", line 215
        'keepEnglishLetter': constants.True,
                                          ^
    SyntaxError: invalid syntax

Successfully installed requests
Cleaning up...
$ python3.2
>>> import requests
>>> r = requests.get('http://www.google.com')
>>> r.ok
True
>>> 
@Lukasa
Collaborator

These are all genuine Python 3 Syntax Errors that are in libraries included within requests. The errors in chardet don't affect functionality, as in Python 3 chardet2 is imported instead, which does not have these problems. It would be nice if we could somehow exclude the module entirely in Python 3 though.

oauthlib is a separate problem. Looking at the code in auth.py, the Syntax Errors raised when importing oauthlib cause the import to fail, and that's handled by the except block here. In the Python 3 case, that except block allows you to use the other Auth methods in that file, but will cause OAuth1 to fail. (For detail, it fails with a NameError because Client was not successfully imported.)

Interestingly, all of the Syntax Errors in oauthlib are caused by unicode literals, which means they will stop being errors in Python 3.3. It's @kennethreitz 's call, but I know that he's planning to drop Python 3.2 as a supported version sometime after the release of 3.3, when this problem will go away.

@kennethreitz

Hmm, I vote to wait for Python 3.3 :)

@yegle

seems this is still a problem?

pip install on Python 3.3.0 still has this problem.

(py3kvenv) yegle@yegle-laptop ~/git/requests/requests/packages/chardet $ python constants.py 
  File "constants.py", line 46
    False = __builtin__.False
                            ^
SyntaxError: invalid syntax
@kennethreitz
Owner

It is a known problem.

@piotr-dobrogost

@kennethreitz Could you point us to some details on this known problem?

@slingamn

This comes up a lot; see #832, #869. Basically, these messages are harmless. The files are not syntactically valid for Python 3, but we don't import them when Python 3 is detected.

@kennethreitz
Owner

I wish I could figure out a better solution :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.