您好我正在尝试安装python-twitter
,其中一个依赖项HTTPLIB2
给了我很多问题。我上下搜索了互联网,但也许我不知道正确的关键词是什么。这是问题所在。
我正在安装python-twitter
。我按"pip install -r requirements.txt"
安装要求,或逐个执行,例如"pip install httplib2"
。然后我运行"python setup.py install"
。它很高兴但"python setup.py test"
失败,因为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
但我认为打印错误是python 2和3之间的不兼容。为什么我得到这个,而我明显有python 2.7(我检查并卸载并重新安装HTTPLIB2)。 非常感谢您的帮助
答案 0 :(得分:3)
python2.7 -m pip install -t lib/ -r requirements.txt
答案 1 :(得分:2)
以防万一,当您使用python3版本的pip安装httplib2然后使用python2执行它时会发生这种情况。
例如,在手动创建环境时会发生这种情况:
pip install -t lib/ -r requirements
在创建AppEngine标准环境供应商文件夹时会发生这种情况。
这是因为与大多数库相反,httplib2对python2和python3有完全不同的版本。