2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Apple Silicon で psycopg2 (python3用pgsqlライブラリ) をインストール

Last updated at Posted at 2020-11-19

Apple Silicon psycopg2 インストール作業メモ 2020/11/19

1, python3,pip3はos(Big Sur 11.1beta)バンドルのものを使う

$ which python3
/usr/bin/python3

$ python3 -V
Python 3.8.2

pip3は直接呼び出すとwarning出るので回避
alias pip3='/usr/bin/python3 -m pip'

$ pip3 -V
pip 20.2.4 from /Users/myname/Library/Python/3.8/lib/python/site-packages/pip (python 3.8)

2, Postgresqlをインストール
$ cd ~
$ wget https://ftp.postgresql.org/pub/source/v12.5/postgresql-12.5.tar.bz2
$ tar xvfz <上のファイル>
$ cd pgsql
$ ./configure
$ make
$ sudo make install
$ vi ~/.zshrc
export PATH=/usr/local/pgsql/bin:$PATH

ライブラリを使いたいだけなのでユーザなどは作らない

3, Opensslをインストール
$ cd ~
$ git clone git://git.openssl.org/openssl.git
$ cd openssl
$ vi Configurations/10-main.conf

1618 "darwin64-arm64-cc" => { inherit_from => [ "darwin64-arm64" ] }, # "His toric" alias
1619 "darwin64-arm64" => {
1620 inherit_from => [ "darwin-common" ],
1621 CFLAGS => add("-Wall"),
1622 cflags => add("-arch arm64"),
1623 lib_cppflags => add("-DL_ENDIAN"),
1624 bn_ops => "SIXTY_FOUR_BIT_LONG",
1625 asm_arch => 'aarch64_asm',
1626 perlasm_scheme => "macosx", <----- ここを ios から macosxに書き換える
1627 },

$ ./Configure darwin64-arm64-cc --prefix="/usr/local/openssl-arm"
$ make
$ make test
$ sudo make install

$ vi ~/.zshrc
export LIBRARY_PATH=/usr/local/openssl-arm/lib:$LIBRARY_PATH
$ source ~/.zshrc

4, psycopg2をインストール
$ pip3 install psycopg2

以上

注:コンパイラがOSバージョンについてのエラーを吐くときは
以下の環境変数をセットしてください。
SYSTEM_VERSION_COMPAT=1

いずれこれは不要になるでしょうからその時は削除してください。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?