2

Hello I am trying to install python-twitter and one of the dependencies HTTPLIB2 is giving me a lot of problems. I have searched the internet up and down but maybe I do not know what the right key words are. Here is the problem.

I am installing python-twitter. I install the requirements either by "pip install -r requirements.txt" or doing them one by one through for example "pip install httplib2". Then I run "python setup.py install". It's happy but then "python setup.py test" fails as followed with an error on import HTTPLIB2.

python setup.py test
running test
running egg_info
writing requirements to python_twitter.egg-info/requires.txt
writing python_twitter.egg-info/PKG-INFO
writing top-level names to python_twitter.egg-info/top_level.txt
writing dependency_links to python_twitter.egg-info/dependency_links.txt
reading manifest file 'python_twitter.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching '.DS_Store'
writing manifest file 'python_twitter.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
File "setup.py", line 73, in <module>
    Main()
  File "setup.py", line 66, in Main
    setuptools.setup(**METADATA)
  File                            

....

<deleted these parts to save space>
    module = __import__('.'.join(parts_copy))
  File "/Users/ME/Downloads/python-twitter-1.0/twitter_test.py", line 30, in <module>
    import twitter
  File "/Users/ME/Downloads/python-twitter-1.0/twitter.py", line 65, in <module>
    import oauth2 as oauth
  File "/usr/local/lib/python2.7/site-packages/oauth2/__init__.py", line 32, in <module>
    import httplib2
  File "/usr/local/lib/python2.7/site-packages/httplib2/__init__.py", line 347
    print('%s:' % h, end=' ', file=self._fp)
                    ^
SyntaxError: invalid syntax

But I thought the print error was an incompatibility between python 2 and 3. Why am I getting this while I clearly have python 2.7 (I checked and uninstalled and reinstalled HTTPLIB2). Thanks much for your help

ritesh
  • 907
  • 3
  • 11
  • 31
Haleh H.
  • 21
  • 1
  • I just needed to change HTTPLIB2 version in my requirements.txt to httplib2==0.7.7 pip installs the latest version which is apparently not compatible with python 2.7. This question needs to be closed. Thanks. – Haleh H. Jun 27 '13 at 17:21

2 Answers2

3

i had a same issue. It seems to be python2.7 and 3.x version conflict issue and resolved by

python2.7 -m pip install -t lib/ -r requirements.txt
Terry Cho
  • 608
  • 6
  • 14
2

Just in case, this happens when you install httplib2 with a python3 version of pip and then execute it with python2.

This happens for example when creating manually an environment with:

pip install -t lib/ -r requirements

As it happens when creating an AppEngine standard environment vendor folder.

This happens because contrary to most of the libraries, httplib2 has completely different versions for python2 and python3.

txomon
  • 642
  • 1
  • 6
  • 21