Python開発環境

jupyter lab

Pythonで開発する時には、Visual Studio Codeが便利で利用していますが、Pythonの統合開発環境として公開されている、JupyterLabを利用してみました。こちらは、ブラウザーベースの開発環境ですが、「JupyterLab」のデスクトップアプリ「JupyterLab App」の記事にある様にデスクトップアプリもリリースされている様です。

Windows環境にPythonをインストール(python-3.10.4-amd64.exe)した状態で設定しています。

C:\python_kb>pip install jupyterlab
Collecting jupyterlab
  Downloading jupyterlab-3.3.4-py3-none-any.whl (8.7 MB)
     ---------------------------------------- 8.7/8.7 MB 7.7 MB/s eta 0:00:00
Collecting jupyter-server~=1.4
  Downloading jupyter_server-1.16.0-py3-none-any.whl (343 kB)
     ---------------------------------------- 343.1/343.1 KB 7.2 MB/s eta 0:00:00
Collecting tornado>=6.1.0
  Downloading tornado-6.1.tar.gz (497 kB)
     ---------------------------------------- 497.4/497.4 KB 4.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done

<SNIP>

Successfully installed MarkupSafe-2.1.1 Send2Trash-1.8.0 anyio-3.5.0 argon2-cffi-21.3.0 argon2-cffi-bindings-21.2.0 asttokens-2.0.5 attrs-21.4.0 babel-2.10.1 backcall-0.2.0 beautifulsoup4-4.11.1 bleach-5.0.0 certifi-2021.10.8 cffi-1.15.0 charset-normalizer-2.0.12 colorama-0.4.4 debugpy-1.6.0 decorator-5.1.1 defusedxml-0.7.1 entrypoints-0.4 executing-0.8.3 fastjsonschema-2.15.3 idna-3.3 ipykernel-6.13.0 ipython-8.2.0 ipython-genutils-0.2.0 jedi-0.18.1 jinja2-3.1.1 json5-0.9.6 jsonschema-4.4.0 jupyter-client-7.3.0 jupyter-core-4.10.0 jupyter-server-1.16.0 jupyterlab-3.3.4 jupyterlab-pygments-0.2.2 jupyterlab-server-2.13.0 matplotlib-inline-0.1.3 mistune-0.8.4 nbclassic-0.3.7 nbclient-0.6.0 nbconvert-6.5.0 nbformat-5.3.0 nest-asyncio-1.5.5 notebook-6.4.11 notebook-shim-0.1.0 packaging-21.3 pandocfilters-1.5.0 parso-0.8.3 pickleshare-0.7.5 prometheus-client-0.14.1 prompt-toolkit-3.0.29 psutil-5.9.0 pure-eval-0.2.2 pycparser-2.21 pygments-2.12.0 pyparsing-3.0.8 pyrsistent-0.18.1 python-dateutil-2.8.2 pytz-2022.1 pywin32-303 pywinpty-2.0.5 pyzmq-22.3.0 requests-2.27.1 six-1.16.0 sniffio-1.2.0 soupsieve-2.3.2.post1 stack-data-0.2.0 terminado-0.13.3 tinycss2-1.1.1 tornado-6.1 traitlets-5.1.1 urllib3-1.26.9 wcwidth-0.2.5 webencodings-0.5.1 websocket-client-1.3.2

C:\python_kb>

起動

C:\python_kb>jupyter lab
[I 2022-04-27 09:46:41.588 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-04-27 09:46:41.604 ServerApp] nbclassic | extension was successfully linked.

Jupyter Labが起動してきます

Jupyter Lab

Markdownでコメントを入れて、キー操作で処理する事も出来ます。

Markdown

実行結果 (1年間の週数)

CTL、SHIFTキーとの組み合わせで操作する事が出来ます。

サンプルコードでScrapingしてみます

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome import service as fs
from selenium.webdriver.chrome.options import Options
import time
import pandas as pd

chromedriver = "C:\Engineer\python\python_kb\chromedriver.exe"
chrome_service = fs.Service(executable_path=chromedriver)

options = Options()
driver = webdriver.Chrome(service=chrome_service, options=options)
## driver = webdriver.Chrome(options=options)

url = "https://www.google.com/search?q=旅行"
driver.get(url)
time.sleep(3)

### Put Elements Name from Source Code.
list_page = driver.find_elements(by=By.CLASS_NAME, value="tF2Cxc")

for article in list_page:
    print(article.text)
driver.quit()

以下の様に結果が表示されます

Crawl

Reference

Download : ChromeDriver

JupyterLab Documentation

JupyterLab Github

参考:図解!Jupyter Labを徹底解説!

カテゴリー:

最近のコメント

表示できるコメントはありません。