环境:win10 Python3.6.4
第一次直接使用pip install Twisted命令安装,报错,过程及结果如下:
直接使用pip命令安装twisted报错图1
直接使用pip命令安装twisted报错图2
观察错误提示,需要 Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
但是Python3.6.4版本的vstools大小为4GB,但是不安装这个vstools又无法安装vc 14,幸好https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted提供了各种大量.whl文件,"Wheel" is a built, archive format that can greatly speed installation compared to building and installing from source archives.
进入该网站,crtl+F twisted 下载图中的.whl文件
请根据自己环境下载相应版本,当然 也可以一个一个尝试
如果不适配当前环境则会报出如下错误:
.whl文件和当前环境不适配时报的错误
如果适配当前环境,则cmd会有如下输出:
注意:pip得是全局命令,在.whl文件所在目录执行安装命令
.whl文件适配当前环境的安装过程图
然后执行python命令,导入twisted试一下,看是否真的成功:
尝试导入twisted,注意模块名是小写的,小编特意大写试了一下
导入没有输出,说明安装成功。
领取专属 10元无门槛券
私享最新 技术干货