重装python,有些失败经验,成功的写在最后
安装好brew后
brew install openssl
打开Python3.6.8源码包里的Modules/Setup.dist
文件
打开这五行的注释
_socket socketmodule.c
SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
然后
export LDFLAGS="-L\$(brew --prefix openssl)/lib"
export CFLAGS="-I$(brew --prefix openssl)/include"
./configure --prefix=/your_install_path --enable-optimizations
make
make install
其中--enable-optimizations
必须
以上均失败了,用stackoverflow.com/questions/23548188/how-do-i-compile-python-3-4-with-custom-openssl
以上均失败了,用stackoverflow.com/questions/46457404/how-can-i-compile-python-3-6-2-on-macos-with-openssl-from-homebrew
以上均失败了,最终成功版:
brew --prefix openssl
显示/usr/local/opt/openssl
Recompile Python and explicitly tell it where to find openssl with CPPFLAGS and LDFLAGS.
./configure CPPFLAGS="-I/usr/local/opt/openssl/include/openssl" LDFLAGS="-L/usr/local/opt/openssl/lib" --prefix=/your_install_path
make
make install