0
Attempts to execute example flightaware python script fails:
Users-MacBook-Air:FlightAwareXML3 user$ python flightawareXML01.py
Traceback (most recent call last):
File "flightawareXML01.py", line 9, in <module> import requests
Attempt to install requests via pip fails:
# sudo pip install requests
ImportError: No module named requests
Users-MacBook-Air:FlightAwareXML3 user$ sudo pip install requests
Password:
The directory '/Users/user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting requests
Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests
Users-MacBook-Air:FlightAwareXML3 user$ pip --version
QUESTION
Is the SSL Certificate preventing the requests install?
Apparently the Mac has two versions of Python installed:
pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)
Users-MacBook-Air:FlightAwareXML3 user$ pip3 --version
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)
Users-MacBook-Air:FlightAwareXML3 user$ which python
/usr/bin/python
Attempt to install via pip3:
Users-MacBook-Air:FlightAwareXML3 user$ sudo pip3 install requests
Password:
The directory '/Users/user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting requests
Downloading https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl (88kB)
100% |████████████████████████████████| 90kB 94kB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 135kB 102kB/s
Collecting certifi>=2017.4.17 (from requests)
Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
100% |████████████████████████████████| 151kB 130kB/s
Collecting idna<2.7,>=2.5 (from requests)
Downloading https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 57kB 137kB/s
Collecting urllib3<1.23,>=1.21.1 (from requests)
Downloading https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl (132kB)
100% |████████████████████████████████| 135kB 163kB/s
Installing collected packages: chardet, certifi, idna, urllib3, requests
Successfully installed certifi-2018.4.16 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22
You are using pip version 8.0.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Attempt to run python script:
Users-MacBook-Air:FlightAwareXML3 user$ python flightawareXML01.py
Traceback (most recent call last):
File "flightawareXML01.py", line 9, in <module>
import requests # sudo pip install requests
ImportError: No module named requests
Questions:
- Is the execution of the .py file performed by Python 2.7 or 3?
- How can the root cause / corrective action be diagnosed for the pip install failures?
UPDATES
Success running python script with python3
python3 flightawareXML01.py
Python 2.7 openSSL query results:
Users-MacBook-Air:FlightAwareXML3 user$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2g 1 Mar 2016
Users-MacBook-Air:FlightAwareXML3 user$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 0.9.8zh 14 Jan 2016