komekichix’s diary

日々の仕事、生活でぶち当たった問題の解決策を書き残しています。あなたのお役に立てれば幸いです。

Python

【Python】JupyterLabのフォントを変更する

JupyterLabの標準フォントだと全角文字、半角文字が判別できないです。特にスペースは絶望的です。 見やすいフォントに変更しましょう。 おすすめは'Ricty Diminished'です。 (標準ではインストールされていないフォントですので、こちらにアクセスし、「Ri…

【Python】selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.

JupyterLabで作成したプログラムを.pyに変換して実行すると、webdriver.Chrome()のところで下記のエラーが出ました。... FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver' ... selenium.common.exceptions.WebDriverException: Mess…

【Python】Pythonのデータ型 リスト型

基本型 spam = ['cat', 'bat', 'rat', 'elephant'] spam[1] -> ‘bat’ 多次元 spam = [['cat', 'bat'], [10, 20, 30, 40, 50]] spam[0] -> ['cat', 'bat'] spam[1][4] -> 50 ■後ろからの参照 spam = ['cat', 'bat', 'rat', 'elephant'] spam[-2] -> 'rat' spa…

【Python】UnicodeEncodeError: 'cp932' codec can't encode character

Windowsのpythonでprint関数を使用すると、 UnicodeEncodeError: 'cp932' codec can't encode character が発生することがあります。理由と対処法を以下に記します。 Pythonでは文字列はUTF-8で処理されます。一方、Windowsでは標準出力へはCP932(シフトJIS…

【Python】オフラインでpyinstallerを導入する際の注意点

オフライン環境上でPyInstallerの導入に手こずったので対処方法を記録しておきます。 ■ pyinstallerが実行できない pip install --no-deps pyinstaller-4.9-py3-none-win_amd64.whl としてpyinstallerをインストールします。 ところが、コマンドプロンプトか…

【Python】JupyterLab failed to buildの対処(jupyterlab_variableinspector)

Variable InspectorはJupyter Labで変数の中身が確認できる拡張機能です。インストール中にエラーが出た際の対処方法をメモします。 インストール手順 >jupyter labextension install @lckr/jupyterlab_variableinspector →エラーになりました。RuntimeError…

【Python】URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)>

import urllib.request as requrl = ページアドレスresponse = req.urlopen(url)とするとSSLCertVerificationErrorが出ました。以下を追加すると解決します。 import sslssl._create_default_https_context = ssl._create_unverified_context