以win10坏境为例:
直接
pip install pymssql
会出现以下报错:
pip install pymssql
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/pymssql/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/pymssql/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/pymssql/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/pymssql/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/pymssql/
ERROR: Could not find a version that satisfies the requirement pymssql (from versions: none)
ERROR: No matching distribution found for pymssql
哪怕是用了镜像,还是会有这上面这样的报错
pip install pymssql -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
最后通过以下方式解决(保证你的电脑上安装了Anaconda,我装的最新python3.9的Anaconda):
到Anaconda官网,找到pymssql的安装包,我电脑是64位就选择这个 (注意看操作系统型号和py版本)
ctrl+R,输入cmd,进到命令行界面,然后
cd到刚刚下载的tar.bz2文件所处的目录,比如我的是下载到了Downloads文件夹,在命令行输入
cd ./Downloads conda install --use-local pymssql-2.2.3-py39h2bbff1b_0.tar.bz2
然后在pycharm里就可以直接Import pymssql了~



