I have a raspberri Pi 2 B. I'm learning about python and trying to use Requests library.
I have python3 and python3.2:
pi@raspberrypi ~/python_programming $ python3
python3 python3.2-config python3.2mu-config python3mu
python3.2 python3.2mu python3-config python3mu-config
I have installed pip:
pi@raspberrypi ~/python_programming $ sudo apt-get install python3-pip
pi@raspberrypi ~/python_programming $ pip-3.2 --version
pip 1.1 from /usr/lib/python3/dist-packages (python 3.2)
When I try to install Requests library and I'm getting:
pi@raspberrypi ~/python_programming $ pip-3.2 install --user requests
Requirement already satisfied (use --upgrade to upgrade): requests in /home/pi/.local/lib/python3.2/site-packages
Cleaning up...
Running the interpreter (python3 or python3.2) and trying to import Requests library triggers the following error:
pi@raspberrypi ~/python_programming $ python3
Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.2/site-packages/requests/__init__.py", line 52, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/home/pi/.local/lib/python3.2/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 169
for prefix in [u'*.', u'.']:
^
SyntaxError: invalid syntax
What is going on? Why cannot I use import statement?
This might be an compatibility issue with requests and Python 3.2
You should try to upgrade to Python 3.3+, or use Python 2.7 instead.
Explanation: Just came across your post while searching for the cause of a broken test. Travis CI got the same error as you when it ran the code that imported requests using Python 3.2. However, the same code works fine on 2.7, 3.3 to 3.6, pypy, and pypy3. Hence, my suspicion that it is a compatibility issue.
Hope that helps!