我试图在Raspberry Pi上设置twitter api Twython,但在第一行之后不断收到无效的语法错误。我可以在一个单独的Ubuntu机器上运行它,而不是错误,所以它可能与twython本身的安装有关。我在论坛上搜索过,大多数错误都是由于导入错误造成的。不知道这个代码在这里发生了什么。我使用命令sudo pip install twython使用pip来安装twython。
pi@raspberrypi:~ $ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from twython import Twython
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python2.7/site-packages/twython/__init__.py", line 24, in <module>
from .api import Twython
File "/home/pi/.local/lib/python2.7/site-packages/twython/api.py", line 15, in <module>
import requests
File "/home/pi/.local/lib/python2.7/site-packages/requests/__init__.py", line 84, in <module>
from urllib3.contrib import pyopenssl
File "/home/pi/.local/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 13, in <module>
from cryptography.hazmat.primitives.asymmetric import dsa, rsa
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 8, in <module>
from fractions import gcd
File "/usr/lib/python2.7/fractions.py", line 7, in <module>
from decimal import Decimal
File "/usr/lib/python2.7/decimal.py", line 140, in <module>
import numbers as _numbers
File "numbers.py", line 1
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
^
SyntaxError: invalid syntax