Poetryã®ã³ãã³ã
Poetyã®ã³ãã³ãã¯å¿ããã¡ãªã®ã§ãã¡ã¢ãã¦ããã¾ãã
ä¾ãã°ãPython 3.9.8ãã¤ã³ã¹ãã¼ã«ããå ´åã
pyenv install 3.9.8
pyenvã使ç¨ãã¦ãããã¸ã§ã¯ããã£ã¬ã¯ããªã§Python 3.9.8ã使ç¨ããã
pyenv local 3.9.8
poetryããã¸ã§ã¯ããã£ã¬ã¯ããªã§ãpoetryã®ä»®æ³ç°å¢ãåä½æã
poetry env use $(pyenv which python)
ä»®æ³ç°å¢ãæ£ããã¢ã¯ãã£ãã«ãªã£ã¦ãããã¨ã確èªã
poetry shell
ä»®æ³ç°å¢ãã¢ã¯ãã£ããªç¶æ
ã§å®è¡ã
python XXXX.py
ãããã¯
poetry run python XXXX.py
pandasã¤ã³ã¹ãã¼ã«æã®ã¨ã©ã¼
表é¡ã®éããPandasãåã¤ã³ã¹ãã¼ã«æå®ãããä¸è¨ã®ãããªã¨ã©ã¼ãåºã¾ããã
AttributeError: partially initialized module 'pandas' has no attribute '_pandas_parser_CAPI' (most likely due to a circular import)
å¤å°é£åããã®ã§ã解決æ¹æ³ãã¡ã¢ãã¦ããã¾ãã
ã¡ãªã¿ã«ã¨ã©ã¼ãåºåãããã®ã¯ãã¼ã¸ã§ã³ã¯2.2.0
解決æ³
ã¾ãpip uninstall pandas
ã§ã¢ã³ã¤ã³ã¹ãã¼ã«ãã¦ããpip install pandas==2.1.0
ã§æ§ãã¼ã¸ã§ã³ãã¤ã³ã¹ãã¼ã«ãããç´ãã¾ããã
Pythonã§ãã使ãã³ã¼ãï¼ãã®ï¼ãPandasç·¨
publicjournal.hatenablog.com
publicjournal.hatenablog.com
Pandasã®åºç¤
æ½åº
pythondatascience.plavox.info
åã®æ½åºã¯df.loc[:,['A','B']]
ã§ãããããï¼df[['A','B']]
ã§ãããã
deepage.net
é£çµ
ã¤ãã¬ã¼ã¿
qiita.com
ããã¯å²ã¨ã¯ã¾ãæãã®ã§æ³¨æãapplyå¾ã®é£çµã¯Seriesã使ãã¹ããDataFrameã ã¨ãindexãåããªãã®ã§å¤ã«ãªãã
Jsonãã¡ã¤ã«ã®åãæ±ã
ãã¼ã¿ã®å
大容éãèªã¿è¾¼ã
Dockerã«ããç°å¢æ§ç¯
å æ¥ãå³æ¸é¤¨ã«è¡ã£ããè¯ãããªæ¬ãç½®ãã¦ãã£ãã®ã§åãã¦ãã¾ãããæä½éã®æ©è½ã使ãããªãããã«å¿ è¦ãªç¥èãä¸å¯§ã«è§£èª¬ãã¦ããè¯æ¸ã§ããã
ããããã°ãããã¾ã§Dockerãèªå·±æµã§ä½¿ã£ã¦ãã¾ãããå¿ è¦ãªãã®ã ãã調ã¹ãã ãã§ãä½ç³»çã«ã¯åå¼·ãã¦ãã¾ããã§ãããæè§ãªã®ã§ããããæ©ã«åå¼·ãã¦ã¿ã¾ããåå¼·ãã¦ãã«ããã®è¨äºã«æ¬æ¸ã®è¦ç¹ãã¡ã¢ãã¦ããã¾ãã
- æ¬æ¸ã®ã¡ã¢
- ç°å¢ãç«ã¡ä¸ãã
- dockerã³ãã³ãã®ä¾
- Docker composeã試ã
- Docker composeã®ã³ãã³ã
- ã¤ã¡ã¼ã¸ã®ä½æãbuild
- ã³ã³ããã®ä½æãcreate
- ã³ã³ããã®èµ·åãstartããæ¢åã³ã³ããã®åèµ·åãrestartããæ¢åã³ã³ããã®åæ¢ãstop
- ã³ã³ããã®å»æ£ãrm
- ä¸æ°ã«ã³ã³ãããç«ã¡ä¸ãããupããä¸å¼ã®ã³ã³ãããåæ¢ãã¦å»æ£ãããdown
- ã³ã³ãããå®è¡ãrun
- ç¹å®ã®ã³ã³ããå ã§ã³ãã³ããå®è¡ãexec
- ãã³ãºãªã³ã§è©¦ãã¦ã¿ã
æ¬æ¸ã®ã¡ã¢
ç°å¢ãç«ã¡ä¸ãã
ãã®æ¸ç±ã§ã¯ãã¾ãç°å¢ãç«ã¡ä¸ããã³ãã³ãã¨ãã¦ã次ã®ãã®ãç´¹ä»ããã¦ãã¾ãã
docker run --name tutorial -d -p 80:80 docker/getting-started
ã³ãã³ãã«ã¤ãã¦ã¯æ¬¡ã®éãã
ã³ãã³ã | 説æ |
---|---|
run |
ã³ã³ãããä½æããå®è¡ããã³ãã³ããcontainer ã¨ããåèªã¯çç¥å¯ã |
name tutorial |
ãã¦ã³ãã¼ãããã³ã³ããã«ååãä»ããããã®å¼æ°ãä»åã¯tutorial ã¨ããååãæå®ããã¦ãããããã®å¼æ°ãæå®ããªãå ´åã§ããèªåçã«ååãä»ããããã |
p 80:80 |
ä»®æ³ã³ã³ãã¥ã¼ã¿å ã¨ãã¹ãã³ã³ãã¥ã¼ã¿å´ãæ¥ç¶ããããã®å¼æ°ã`80:80`ã¯æ¥ç¶ãããã¼ãçªå·ã示ãã¦ããããã¹ãã³ã³ãã¥ã¼ã¿å´ã§80çªãã¼ãã§æ¥ç¶ããã¨ãä»®æ³ã³ã³ãã¥ã¼ã¿å´ã®80çªãã¼ãã«æ¥ç¶ãããã |
docker/getting-started |
åãè¾¼ãã¤ã¡ã¼ã¸ãã¡ã¤ã«ãæå®ããããã®å¼æ°ã |
dockerã³ãã³ãã®ä¾
æ¬æ¸ã§ç´¹ä»ããã¦ãã代表çãªã³ãã³ãã«ã¤ãã¦ãè¨è¼ãã¦ããã¾ãã
ã³ã³ããã®åæ¢ãåé¤
// ã³ã³ããã®åæ¢ docker stop tutorial // ã³ã³ããã®ä¸è¦§ã表示 docker ps -a // åé¤ docker rm tutorial
ãã¨ã¯ããã®æ¸ç±ã§ã¯ããã¹ã¦ç ´æ£ããã¾ã§ãDockerãã¨è§£èª¬ããã¦ãã¾ãããããã¾ã§ã¯ãã¾ãããããæèãç¡ãã£ãã§ãã»ã»ãä½ãã£ã±ãªãã§æ¾ç½®ã§ããã
// ã¤ã¡ã¼ã¸ãåé¤ docker image re // ã¤ã¡ã¼ã¸ã®ä¸è¦§ã表示ãã¦ãåå¨ããã¤ã¡ã¼ã¸ãç¢ºèª docker image ls
Docker composeã試ã
ã³ãã³ãã ãã§ã¯å¤§å¤ãªã®ã§Docker composeã¨ããDockerã®ç«ã¡ä¸ãè¨å®æ¸ã®æ©è½ãããã¾ããï¼ããã辺ã¯ç¥ã£ã¦ãã話ãªã®ã§ãå²æï¼
ã³ã³ããã¨ã¤ã¡ã¼ã¸ã«ã¤ãã¦ç´¹ä»ããã¦ãã¦ãåã
ã«ã¯æ¬¡ã®ãããªéããããã¾ãã
- ã¤ã¡ã¼ã¸ï¼ããã°ã©ã ã®ãã¨ã¨ãªããã¡ã¤ã«ã®ãããªãã®
- ã³ã³ããï¼ãã®ã¤ã¡ã¼ã¸ã使ã£ã¦ä½æãããã®
åèï¼'Docker のイメージとコンテナ: どう違う?' | CircleCI
Docker composeã®yamlãç·¨éããã«ããã£ã¦ãããªã¥ã¼ã ã®ãã¦ã³ãã¨ããã®ãããã¾ããããªã¥ã¼ã ã¨ããã®ã¯ãOSã«ãã£ã¦å®ç¾©ãããåºåãã§ãããã¹ãã¬ã¼ã¸ã®åä½ã®ä¸ã¤ããã¦ã³ãã®ä»æ¹ã«ã¤ãã¦ã¯æ¬¡ã®éãã§ãã
- ããªã¥ã¼ã ãã¦ã³ããï¼Docker Engineä¸ã§ãã¦ã³ã
- ãã¤ã³ããã¦ã³ããï¼ãã½ã³ã³ã«ä½æãããã¡ã¤ã«ããã£ã¬ã¯ããªã«ãã¦ã³ã
- ã¡ã¢ãªã¼ãã¦ã³ããï¼ãã½ã³ã³ã®ã¡ã¢ãªã«ãã¦ã³ã
Docker composeã®ã³ãã³ã
ã¤ã¡ã¼ã¸ã®ä½æãbuild
docker compose build
ã³ã³ããã®ä½æãcreate
docker compose create
ã³ã³ããã®èµ·åãstartããæ¢åã³ã³ããã®åèµ·åãrestartããæ¢åã³ã³ããã®åæ¢ãstop
docker compose start docker compose restert docker compose stop
ã³ã³ããã®å»æ£ãrm
docker compose rm
ä¸æ°ã«ã³ã³ãããç«ã¡ä¸ãããupããä¸å¼ã®ã³ã³ãããåæ¢ãã¦å»æ£ãããdown
docker compose up -d docker compose down // ã³ã³ãããåé¤ããã¦ãããã確èªãã docker compose images
ã³ã³ãããå®è¡ãrun
runã®å¾ã«ã¯docker-compose.ymlãã¡ã¤ã«ã®serviceå ã®imageåãå ¥åãã
docker compose run httpd bash
ç¹å®ã®ã³ã³ããå ã§ã³ãã³ããå®è¡ãexec
runã¨ã®éãã¯æ¢ã«ã³ã³ãããupããã¦ãããã©ããã¨ããéãã§ãã対話形å¼ã®ã³ãã³ãbushãç«ã¡ä¸ãããã¾ããæ°ããç»é¢ãéãã¦ã»ãã®æä½ãããã®ã¨åãæè¦ã§ã³ã³ãããæä½ã§ãããexitã§bushããåºãã
docker compose up -d docker compose exec httpd bash #exit docker compose down
docker run -d -p 8001:80 docker5-1
ãã³ãºãªã³ã§è©¦ãã¦ã¿ã
åºç¤ã®é¨åãä¸éãèªãã§ã¿ãã®ã§ãèªåã§æãåããã¦ã¿ã¾ããæè¿ã¯ããPythonã使ãã®ã§ãPythonç°å¢ãä½ã£ã¦ã¿ã¾ããæ¬æ¸ã®è§£èª¬ã¨ã°ã°ã£ã¦åºã¦ããä¸è¨ã®ãµã¤ããåèã«åä½ã試ãã¦ã¿ã¾ãã
ã¾ãã¯ä½æ¥ãã£ã¬ã¯ããªãä½æãã
test_docker_python
ã¨ãããã£ã¬ã¯ããªãä½ã£ã¦ã¿ã¾ãããã®ä¸ã«yamlã¨Dockerfileãç½®ãã¦ããã¾ãã
docker-compose.yml
ã¯æ¬¡ã®éãã«è¨å®ãã¾ãããä»åã¯Windowså´ã®Dãã©ã¤ãã®ä¸ã«å¾è¿°ã®test.py
ã¨ããã¹ã¯ãªãããç½®ãã¦ãããã®åä½ã試ãã¾ãã
version: '3' services: python3: build: context: . dockerfile: Dockerfile container_name: 'test_python_env' volumes: - /mnt/d/test://new_dir tty: true
Dockerfile
ãä¸è¨ã®ããã«ä½ã£ã¦ã¿ã¾ãããã使ãã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ãããã¨ããæ³å®ã§ä½æãã¦ã¿ã¾ããã
FROM continuumio/miniconda3 RUN conda create -n chemodel python==3.10 RUN conda install numpy RUN conda install scipy RUN conda install pandas
ã¤ã¡ã¼ã¸ãä½æãã
dockerãèµ·åãã¦ãbuildã³ãã³ããå®è¡ãã¾ãã
buildããæã«ãä¸è¨ã®ãããªã¡ãã»ã¼ã¸ãåºåããã¾ããã
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
ããã¯ããã§ãä¸å¿ãã«ãããã¦ããã£ã½ãã§ãã
ã³ã³ãããä½æãã
èæ¯è²ãè¦ã¥ããã§ãããä¸è¨ã®ããã«å®è¡ãã¾ãã
ã³ã³ãããèµ·åãã
èµ·åããã¦ãããã¨ã確èª
Pythonèµ·å
åãç°¡åã«ä½ã£ãtest.pyãåããã¦ã¿ã¾ãããã¦ã³ãããã¦ããWindowså´ã®ãã¡ã¤ã«ãæå®ãã¾ãã
# test.py import pandas as pd import os path ='test_csv.csv' print(os.path.exists(path)) #pd = pd.read_csv(path)
ãã©ãã«
ä¸è¨ã®ããã«exceã³ãã³ããå®è¡ã§ããªãã¨ãããã©ãã«ãããã¾ãããå ã ã¯ä¸è¨ã®ããã«Docker composeãæ¸ãã¦ãã¾ãã
version: '3' services: python3: build: context: . dockerfile: Dockerfile container_name: 'test_python_env' volumes: - /mnt/d/test://new_dir
ããã ã¨ããã bashãå®è¡ããã ãã§çµãã£ã¦ãã¾ãã¾ãã State ããExit 0ãï¼æ£å¸¸çµäºï¼ã§çµãã£ã¦ãã¾ãã
ãªã®ã§ãä¸è¨ãåèã«tty
ãå
¥ãã¾ããã
teratail.com
ãããã¯docker compose start
ãå¿ãã¦ãåãã¡ãã»ã¼ã¸ã表示ããã¾ãã
WSL2ã«Dockerãã¤ã³ã¹ãã¼ã«ãã
å»å¹´ã®å¤ãããã«æ¡ä»¶ä»ãã§Docker Desktopæåã«ãªãã¾ããã誤ã£ã¦æåã®æ¡ä»¶ã«å½ã¦ã¯ã¾ã£ã¦ãããé¢åãªã®ã§ãç¡åã®æ¹æ³ã模索ãã¦ç°å¢æ§ç¯ããã¾ããã
ãã®æã¯ãããã®è¨äºã調ã¹ã¦æççã«å®æ½ãã¦ãã£ããã®ã®ãã¾ã¨ã¾ã£ã¦ããè¨äºããªãã£ãæ°ããã¾ãããã®ããããæè¿PCãå¤ãã¦Dockerç¡åç°å¢æ§ç¯ããããã¨ããã£ã¦ãã©ããã£ãã®ãå¿ãã¾ããã»ã»ã»ã
ãªã®ã§ãDockerã®ç°å¢æ§ç¯ã®æ¹æ³ãã¡ã¢ãã¦ããã¾ããå ãã¦ãæè¿ã¯è¯ãPythonã使ãã®ã§ãVisual Studio Codeã¨Jupyter Notebookä¸ã§Pythonã使ãæ¹æ³ãæ¸ãã¦ããã¾ãã
- WSL2ãã¤ã³ã¹ãã¼ã«ãã
- Dockerç°å¢ãæ§ç¯ãã
- Visual Studio Codeãèµ·åãã
- åè
WSL2ãã¤ã³ã¹ãã¼ã«ãã
ããã辺ã¯å
¬å¼ããã¥ã¡ã³ããQiitaè¨äºãèªãã ã»ããåãããããã§ããã¨ãã«ãããã¨ãããç¡ããã転è¨ããã®ãé¢åãªã®ã§ãªã³ã¯å
ãåç
§ã®ãã¨ã
www.kagoya.jp
qiita.com
ãNoteã
Dockerç°å¢ãæ§ç¯ãã
Docker Engineãã¤ã³ã¹ãã¼ã«ãã
ãã®è¾ºããªã³ã¯å
ãåç
§ã®ãã¨ã
docs.docker.com
Docker Engineãèµ·åãã
# èµ·å sudo service docker start
# ç¶æ ç¢ºèª sudo service docker status
# åä½ç¢ºèª sudo docker run --rm hello-world
Visual Studio Codeãèµ·åãã
ãã¹ã¯ãããã®ãã¡ã¤ã«ãå¼ã³åºã
teratail.com
detail.chiebukuro.yahoo.co.jp
ja.stackoverflow.com
mecobalamin.hatenablog.com
i-doctor.sakura.ne.jp
teratail.com
zenn.dev
åè
zenn.dev
zenn.dev
zenn.dev
qiita.com
ä¸è¬ã¦ã¼ã¶ã¼ã¸ã®æ¨©éä»ä¸
www.mwsoft.jp
zuma-lab.com
docs.docker.jp
zenn.dev
Pythonã©ã¤ãã©ãªã«é¢ãããã¼ãã·ã¼ã
以åããããã°ã©ãã³ã°ä½æ¥å¹çåã®ããã«ãPythonã§ãã使ãã©ã¤ãã©ãªã«ã¤ãã¦ã¾ã¨ãã¦ãã¾ããã
publicjournal.hatenablog.com
publicjournal.hatenablog.com
æè¿ããã¼ãã·ã¼ããTwitterã§æµãã¦ããã®ã§ããªã³ã¯ãè²¼ã£ã¦ããã¾ãã