1、首先用pip来安装pymysql
1
|
pip install mysql |
报错:
1
|
cryptography requires setuptools 18.5 or newer, please upgrade to a new version |
2、我想到的是更新pip
1
|
sudo pip install --upgrade pip |
其实需要更新的是setuptools:
1
|
sudo pip install -t /usr/local/lib/python3 .6 /site-packages/ setuptools |
3、使用pip将pymysql安装到想要的地方
针对多python版本的情况:
安装到python2.7:
1
|
sudo pip install pymysql |
安装到python3.4:
1
|
sudo pip install -t /usr/local/lib/python3 .4 /site-packages/ pymysql |
安装到python3.6:
1
|
sudo pip install -t /usr/local/lib/python3 .6 /site-packages/ pymysql |
安装到虚拟环境中:
1
|
sudo pip install -t ~ /Pycharm/py36env/lib/python3 .6 /site-packages pymysql |
报错:
1
|
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 |
解决方式:
1
|
sudo pip --trusted-host pypi.python.org install -t ~ /PycharmProjects/py36env/lib/python3 .6 /site-packages/ mysql |
问题解决。