Python+jupyter環境構築(M1 mac対応)
MacへのPython+jupyter環境構築(M1 mac対応)
macにhomebrewをインストール
- homebrewの公式ページにアクセスして
Install Homebrew
のコマンドをターミナルにコピペして実行 - homebrewのPATHを通す(Next stepsで出てくるコマンドを実行するだけ)
"Operation not permitted"に対する対策
なぜかls
がタイトルのエラーで通らなかったので調べてみるとターミナルにアクセス権限振られてないことが問題のよう。
システム環境設定->セキュリティとプライバシー->フルディスクアクセスにターミナル(またはiTerm)を追加することで解消。
pyenvをインストールする前に
pandas
をimportすると下記のエラーが出る。pyenv経由でpythonをインストールした場合に発生する模様。
pythonをインストールした後に気づいたがpythonの再インストール必要なため、pythonインストール前に対処。
UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.
対処方法はxz
をインストールする。
$ bash install xz
pyenvのインストール
# pyenvのインストール $ brew install pyenv # zshの設定 $ echo 'eval "$(pyenv init --path)"' >> ~/.zshrc # pyenvのバージョン確認 $ pyenv -v # pyenvでインストール可能なpythonのバージョン一覧の取得 $ pyenv install -l # pythonのインストール(今回の設定では3.10.0をインストール) $ pyenv install 3.10.0 # pyenvでインストールした環境をディレクトリ下に適用 $ pyenv local 3.10.0 # pythonのバージョン確認 $ python -v
xz
をインストール後の再インストール時は下記を実施(事前にxzインストールしたときに必要になるかは未検証)
$ prefix=$(brew --prefix) $ export LDFLAGS="-L$prefix/opt/xz/lib $LDFLAGS" $ export CPPFLAGS="-I$prefix/opt/xz/include $CPPFLAGS" $ export PKG_CONFIG_PATH="$prefix/opt/xz/lib/pkgconfig:$PKG_CONFIG_PATH" $ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.10.0
poetryのインストール
公式ドキュメントのDocumentaion->Installation
の下記コマンドを実行
# poetryのインストール curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - # 現在のshellに設定を反映 source $HOME/.poetry/env
poetryを用いたpythonモジュールインストール
$ poetry init $ poetry add jupyter jupyterlab pandas tqdm $ poetry run jupyter lab
参考文献
GABA Business Advantage Level 4-2(A colorful new office -"Expressing"-)②
頻出
- I agree with (someone) vs I agree on (topic)
- confidential information
新出
- demotivate・・・モチベーションを下げる。e.g., If they have to clean after work, they'll be demotivated.
- People show their personalities (personal taste).
専門分野に関わるフレーズ
Machine learning is more profitable in the short term. (in the short termがbusinessっぽいらしい)
throw someone off・・・新しいことで人を混乱させる。The new system might throw some people off.
あまり使わなそうな単語・フレーズ
- sit-com = situation comedy, drama = sad storyという違いがあるらしい。e.g., Friends is a sit-com.
jupyterlab-vimのvim keybindingsでescが動作しない問題の解決方法
jupyterlabのタブのsettings
->Advanced Setting Editor
->Keyboard Shortcuts
のUser Preferences
に下記を貼り付ける。
{"shortcuts": [ { "command": "notebook:enter-command-mode", "keys": [ "Escape", ], "selector": ".jp-Notebook.jp-mod-editMode", "disabled": true } ] }
GABA Business Advantage Level 4-2(A colorful new office -"Expressing"-)
レッスン時に使える表現
- Wat do you mean? = Care to explain?
意見聞く
- What should we ...?
- What should we put on the front door?
- Where do you think ...?
- Where do you think the reception area should be?
意見を述べる
- I think ...
- I'm sure ...
- 確信のニュアンス
- 期待のニュアンス
- We should ...
- I like ...
- Personally, ...
- In my opinion, ...
- According to ..., ...
相手の意見に対する評価
- It's corny = It's not cool
extra
- go over the line = do too much (bad)
- Do you think we will go over the threshold and think AI will be competent?
- competent = can be reliable in the majority
- backfire = plan doesn't work
あまり使わなそうな単語・フレーズ
- stuffed toys (ぬいぐるみ)
- professionlal look = not casual look
GABA Business Advantage Level 4-1(Watch your step -"Meeting People"-)
単語
- a foreman = a project leader
フレーズ
- I was wondering if you could help me.
- I should've introduced myself.(先に自己紹介すべきだった(反省))
- I have a 12:00 appointment with Gary.
- Watch your step! = Be caraful walking!
- a pile of bricks(山積みのコンクリート、(私見)concreateは不可算名詞だから避けたのかな?)
- I'm with (Organization)
- = I work for (Organization) = I belong to (Organization) = I'm from (Organization)
- Could you please help me?
- I'd like coffee, if that's okay?
- Just black, no sugar.
- (after small talk) Let's get down to business!
概念的な内容
go through
とgo past
はgo through
が中を通るイメージで、go past
が側を通るイメージ
あんま使わなそうだけど登場した単語・フレーズ
- a spade = a shovel(スコップ)
- scaffolding(工事現場でよく見る周りの鉄パイプ組み立ててるやつ)
GABA Level Check
GABAの体験レッスンでレベルチェックしてきました。 レベルチェックの結果、Business level 4からスタートになりました。
以下はテストのフィードバックです。
Goals(目標)
- Improve listening
- Make better output in discussions
Strong Points(長所・強み)
- Response time
- Vocabulary
Points to Improve(課題点)
- Natural Phrases
- Accuracy-Describing
- Prepositions(前置詞), Verb conjugation(動詞の活用)
Customized Study Advice(学習アドバイス)
- Take many instructors
- Record lesson
ABC141の解法
本日開催されたABC141のD問題までの解法について書きます。
A: Weather Prediction
特に工夫はなく、if文を連打してAC
S = input() if S == 'Sunny': print('Cloudy') elif S == 'Cloudy': print('Rainy') elif S == 'Rainy': print('Sunny')
B: Tap Dance
問題文から奇数のときはL以外、偶数のときはR以外を出さないとYesにならないことがわかる。 これらを判定し、もしNoが出た場合はexitするように書くことでAC。
from sys import exit S = input() for i in range(len(S)): num = i+1 if num % 2 == 1 and S[i] == 'L': print('No') exit() if num % 2 == 0 and S[i] == 'R': print('No') exit() print('Yes')
C: Attack Survival
参加者それぞれの正解数をカウントして、(全体正解数Q-参加者の正解数V)を計算することで、 参加者それぞれの不正解数がわかる(今回の問題では不正解数分だけ最初にもっていたKポイントから減算されるという問題設定)。 よって、Q-V がKを超えるかどうかを判定し、AC。
N, K, Q = map(int, input().split()) A = [int(input()) for i in range(Q)] victory_cnt = [0] * N for i in range(Q): victory_cnt[A[i]-1] += 1 for v in victory_cnt: if (Q-v) >= K: print('No') else: print('Yes')
D: Powerful Discount Tickets
コンテスト中に方針を立てることはできたが、TLEを解消できなかった。 コンテスト終了後、プライオリティキューを用いてsubmitすることでTLEを出さずにACできた。 方針としては、最大値に対して割引の回数だけ割引し続けるという方針でいくとうまくいく。 このとき、割引前の最大値と、その最大値に対して割引を適用したあとでは最大値が入れ替わる可能性があることが今回のポイントとなる。 それを踏まえて、プライオリティキューで最大値を取り出して、(最大値//2)をプライオリティキューに加えて、それに対してまた最大値を取り出すという処理を繰り返すことで対処する。
import heapq N, M = map(int, input().split()) A = list(map(int, input().split())) A_inv = [-a for a in A] heapq.heapify(A_inv) for _ in range(M): max_inv = heapq.heappop(A_inv) heapq.heappush(A_inv, -(-max_inv//2)) print(sum([-a for a in A_inv]))
プログラミングコンテストチャレンジブック [第2版] ?問題解決のアルゴリズム活用力とコーディングテクニックを鍛える?
- 作者: 秋葉拓哉,岩田陽一,北川宜稔
- 出版社/メーカー: マイナビ
- 発売日: 2012/01/28
- メディア: 単行本(ソフトカバー)
- 購入: 25人 クリック: 473回
- この商品を含むブログ (36件) を見る