安装第三方Python库报错

Mac系统都自带Python环境,我的是Python2,后面我又自己装了Python3。然后安装requests库。执行

sudo pip install requests

发现安装失败,报错
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests

报错原因我猜测是未找到合适的requests 版本,可能requests只支持Python3了
执行

sudo pip3 install requests

安装成功

此时还遇到一个警告:
The directory '/Users/encircle/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

按照提示提示加上 -H标志就好了

sudo -H pip3 install requests
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容