1、首先是想到用pip來(lái)安裝pymysql
pip install mysql
報(bào)錯(cuò):
cryptography requires setuptools 18.5 or newer, please upgrade to a
2、我想到的是更新pip
sudo pip install --upgrade pip
其實(shí)需要更新的是setuptools:
sudo pip install -t /usr/local/lib/python3.6/site-packages/ setuptools
3、使用pip將pymysql安裝到想要的地方,針對(duì)多python版本的情況:
安裝到python2.7:
sudo pip install pymysql
安裝到python3.4:
sudo pip install -t /usr/local/lib/python3.4/site-packages/ pymysql
安裝到python3.6:
sudo pip install -t /usr/local/lib/python3.6/site-packages/ pymysql
安裝到虛擬環(huán)境中:
sudo pip install -t ~/Pycharm/py36env/lib/python3.6/site-packages pymysql
報(bào)錯(cuò):
Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
解決方式:
sudo pip --trusted-host pypi.python.org install -t ~/PycharmProjects/py36env/lib/python3.6/site-packages/ mysql
問(wèn)題解決。