M1-python3.8安装psycopg2

1、更新pip源

python3 -m pip install --upgrade pip

2、安装openssl

这里要记住openssl的路径(下面要用),一般homebrew安装的文件路径都在/opt/homebrew/opt/目录下

brew install openssl

3、安装、启动postgresql

brew install postgresql
brew services start postgresql

3、配置环境变量

这里要使用上面的openssl路径

export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include"

4、安装psycopg2

pip3 install psycopg2

5、安装psycopg2-binary

pip install psycopg2-binary

M1-python3.8安装psycopg2_第1张图片

OK!

你可能感兴趣的:(python,MacBook,M1,Macbook,M1,M1踩坑日记)