无法在 Python 3.2 (Raspberry Pi) 上安装 twython

Can't install twython on Python 3.2 (Raspberry Pi)

我正在尝试安装 twython,但总是出现错误。

第一次尝试:

pi@raspberrypi ~/twython $ sudo pip-3.2 install twython
 Running setup.py egg_info for package requests
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/home/pi/twython/build/requests/setup.py", line 52, in <module>
        exec(f.read(), about)
      File "<string>", line 14
        __cake__ = u'\u2728 \U0001f370 \u2728'
                                             ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

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

  File "/home/pi/twython/build/requests/setup.py", line 52, in <module>

    exec(f.read(), about)

  File "<string>", line 14

    __cake__ = u'\u2728 \U0001f370 \u2728'

                                         ^

SyntaxError: invalid syntax

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/pi/twython/build/requests

接下来,我搜索了错误的最后一行,并按照一些建议确保 setuptoolsez_install 已安装并保持最新,但这没有帮助。

然后我按照 ReadtheDocs 上的备份说明尝试以这种方式安装它:

git clone git://github.com/ryanmcgrath/twython.git
cd twython
sudo python3 setup.py install

但又失败了:

  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 640, in install_item
    self.process_distribution(spec, dist, deps)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 692, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 576, in resolve
    dist = best[req.key] = env.best_match(req, self, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 822, in best_match
    return self.obtain(req, installer) # try and download/install
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 834, in obtain
    return installer(requirement)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 608, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 638, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 828, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1105, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1094, in run_setup
    run_setup(setup_script, args)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 31, in run_setup
    lambda: exec(compile(open(
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 73, in run
    return func()
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 34, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'})
  File "setup.py", line 52, in <module>

Error in atexit._run_exitfuncs:
TypeError: 'NoneType' object is not callable

事实证明,Twython 无法与 Python v3.2 一起使用,因为它依赖于 requests 模块,而 Python 3.2 显然不支持该模块。

Twython 的一位开发人员刚刚在 Twitter 上向我解释了这一点。