0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker内のPythonのModuleをデバッグする方法

Posted at

困り事

  • DockerにPythonの実行環境を立てて開発をしている (module は pip でインストールしている)
  • 何やら、module内でエラーが出ているようにエラーが表示されているが、渡している値は正常のように見えるので何が問題なのかが分からない
  • print文などが仕込むことができればいいのに!!!

やった事

pip show ~~ とする事でそのModuleが格納されているディレクトリ情報を得る事ができます。

$ pip show django

Name: Django
Version: 3.0.5
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: foundation@djangoproject.com
License: BSD
Location: /usr/local/lib/python3.8/site-packages
Requires: piyopiyo
Required-by: hogehoge, fugafuga

ので、 Dockerのコンソールに入って

$ cd /usr/local/lib/python3.8/site-packages/django
$ vim shortcuts.py

デバッグを行いたい適当な場所に print('debug中です〜〜〜') みたいな事を書けば、実行時のログとして出力出来るなどしました。 (エラーも無事解決)

困ったらやってみてくださいまし〜。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?