写前面的话
最近,折腾macbook关于python3安装一些软件包,被整的够呛。因为之前安装过py3环境,所以直接想pip 安装需要的依赖包,结果一上来就报错了!
Can't connect to HTTPS URL because the SSL module is not available.
Brew安装
需要安装brew工具
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
但是结果不是很理想,安装百分之20左右就报错了。
大致是这样:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
出现这个错误的原因是项目太久,tag资源文件太大
解决方式: 命令终端输入
git config --global http.postBuffer 524288000
幸运的事,终于可以下载了,但是又产生问题了:
Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Library/Taps/homebrew/homebrew-core --config core.autocrlf=false --depth=1 -q
Error: Failure while executing: /usr/local/bin/brew tap homebrew/core -q
这是啥情况,百度之好像是没权限,解决方法如下:
sudo chown -R apple:staff
⚠️设备当前名称 不然会报:
chown: apple: illegal user name
最后添加环境变量:
sudo vim .bash_profile
添加
export PATH=/usr/local/bin:$PATH
保存,source .bash_profile使配置修改生效。
重新启动终端
重新配置python环境
删除旧python环境:
open /System/Library/Frameworks/Python.framework/Versions
删除不需要的python版本
重新进行安装
brew install python3
最后生成的python3 在/usr/local/bin下
pip 下载超时错误
pip._vendor.urllib3.exceptions.ReadTimeoutError HTTPSConnectionPool(host='files.pythonhosted.org', , port=443): Read timed out.
解决办法:
pip install --default-timeout=1000 --upgrade pip
最后的建议
使用该指进行安装:
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=1000