I'm trying to add 'PyMySQL, but it keeps throwing
Traceback (most recent call last):
File "/home/john/workspace/Python/sql/sql.py", line 1, in <module>
ImportError: No module named 'PyMySQL'
john@john-PC:$ sudo pip install PyMySQL
The directory '/home/john/.cache/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 '/home/john/.cache/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.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Downloading PyMySQL-0.7.9-py2-none-any.whl (78kB)
100% |████████████████████████████████| 81kB 1.3MB/s
Installing collected packages: PyMySQL
Successfully installed PyMySQL-0.7.9
john@john-PC:$ pip install PyMySQL
Requirement already satisfied (use --upgrade to upgrade): PyMySQL in /usr/local/lib/python2.7/dist-packages
john@john-PC:$ sudo apt-get install python3-pymysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pymysql is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 56 not upgraded.
apt-get install software-properties-common
apt-get update && apt-get dist-upgrade
sudo apt-get install python3-pymysql
sudo apt-get install python3-pymysql for python3
as already answered here at stackoverflow.com