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