1、首先用pip来安装pymysql
pipinstallmysql
报错:
cryptographyrequiressetuptools18.5ornewer,pleaseupgradetoanewversion
2、我想到的是更新pip
sudopipinstall--upgradepip
其实需要更新的是setuptools:
sudopipinstall-t/usr/local/lib/python3.6/site-packages/setuptools
3、使用pip将pymysql安装到想要的地方
针对多python版本的情况:
安装到python2.7:
sudopipinstallpymysql
安装到python3.4:
sudopipinstall-t/usr/local/lib/python3.4/site-packages/pymysql
安装到python3.6:
sudopipinstall-t/usr/local/lib/python3.6/site-packages/pymysql
安装到虚拟环境中:
sudopipinstall-t~/Pycharm/py36env/lib/python3.6/site-packagespymysql
报错:
CouldnotfetchURLhttps://pypi.python.org/simple/requests/:Therewasaproblemconfirmingthesslcertificate:Can'tconnecttoHTTPSURLbecausetheSSLmoduleisnotavailable.-skipping
解决方式:
sudopip--trusted-hostpypi.python.orginstall-t~/PycharmProjects/py36env/lib/python3.6/site-packages/mysql
问题解决。
网友评论