kb84tkhrのブログ

何を書こうか考え中です あ、あと組織とは関係ないってやつです 個人的なやつ

PPP3: pip更新と名前解決

次はpip
pipにもpip3.6って書いたものがあるんだな
pip3とpip3.6は同じもの
pipはpip3.6という名前ではなくpipという名前でシンボリックリンクを張っている
python本体と扱いが違うのはなぜだろう

lxmlをインストール
これは試しに使ってみようくらいのことかな

$ sudo pip install lxml
The directory '/home/vagrant/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/vagrant/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

なにか出てるけどこれはいいんだろうか
「-(中略)-」となってる範囲

Collecting lxml
  Downloading https://files.pythonhosted.org/packages/35/8a/5e066949f2b40caac32c7b2a77da63ad304b5fbe869036cc3fe4a198f724/lxml-4.3.3-cp36-cp36m-manylinux1_x86_64.whl (5.7MB)
    100% |████████████████████████████████| 5.7MB 3.1MB/s 
Installing collected packages: lxml
Successfully installed lxml-4.3.3

成功してるからいいの?

You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

そういえば本には書いてなかったけど
upgradeはするんだよな?
実際のサービス運用ではなんか理由があってしない、みたいなことあるのかな?
やろう

$ pip install --upgrade pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe1c00a7940>: Failed to establish a new connection: [Errno -2] 名前またはサービスが不明です',)': /simple/pip/

えーもうなんなのー
エラーメッセージで検索してみるとnameserverを追加しろとか
名前?ひけてなかったっけ?っていうか引けなきゃなにもできないよなあ

resolv.confを見る

nameserver 127.0.0.53
options edns0

127.0.0.53ってなんだ

先に作ったデスクトップじゃないほうの仮想マシン見てみたら
設定はnameserver 127.0.0.53だけどちゃんと名前解決できてる

再起動しても変わらない
lxmlをアンインストールしてインストールしようとすると同じエラー
何がおかしくなったのか

また検索
ここの情報が信頼できそうな感じ

Ubuntuで「ネームサーバー」の設定を確認する方法 | LFI

このファイルには、ネームサーバーのアドレスとして「127.0.0.53」だけが記述されています。
これは、ネームサーバーへの問い合わせをローカルホストで動く「systemd-resolve」を介して行うようになっているためです。

ふーん
実際の設定は/run/systemd/resolve/resolv.confにあるという

nameserver 10.0.2.3

こんどは10.0.2.3か
なんだこれは
どうやらVirtualBoxが作っているDNSのプロキシらしい
設定がおかしいってわけじゃないんだな
じゃあなんで動いてないの

ちまたでは8.8.8.8を設定しろとか言っている
なにか臭いものにフタをしてるような気もするけどものはためしにやってみる

いろいろと成功

vagrant@vagrant:~$ pip install --user beautifulsoup4
Collecting beautifulsoup4
  Downloading https://files.pythonhosted.org/packages/1d/5d/3260694a59df0ec52f8b4883f5d23b130bc237602a1411fa670eae12351e/beautifulsoup4-4.7.1-py3-none-any.whl (94kB)
    100% |████████████████████████████████| 102kB 69kB/s 
Collecting soupsieve>=1.2 (from beautifulsoup4)
  Downloading https://files.pythonhosted.org/packages/b9/a5/7ea40d0f8676bde6e464a6435a48bc5db09b1a8f4f06d41dd997b8f3c616/soupsieve-1.9.1-py2.py3-none-any.whl
Installing collected packages: soupsieve, beautifulsoup4
Successfully installed beautifulsoup4-4.7.1 soupsieve-1.9.1
vagrant@vagrant:~$ pip freeze
beautifulsoup4==4.7.1
lxml==4.3.3
soupsieve==1.9.1
vagrant@vagrant:~$ pip freeze --user
beautifulsoup4==4.7.1
soupsieve==1.9.1

本ではsoupsieveっていうパッケージは出てきてなかったけど
beautifulsoupのパッケージが分割されたのかな?
それとも16.04だともともと入ってる?それはないか

pip install --userでそのユーザ専用としてパッケージをインストール
pip freeze --userでそのユーザ用にインストールされたパッケージ一覧
というのがあるんだ 知らなかった
ところでなんで一覧のことfreezeっていうんですか