LoginSignup
29
26

More than 1 year has passed since last update.

PythonでModuleNotFoundError: No module named 'XXX'が起きた時の対応

Last updated at Posted at 2020-02-04

表題の対処メモです。
今回はWTFormsが無い想定です。

まずはpip showでモジュールが存在するか確認

pip show WTForms
Name: WTForms
Version: 2.2.1
Summary: A flexible forms validation and rendering library for Python web development.
Home-page: https://wtforms.readthedocs.io/
Author: Thomas Johansson, James Crasta
Author-email: wtforms@simplecodes.com
License: BSD
Location: /Users/XXX/.pyenv/versions/3.7.5/lib/python3.7/site-packages
Requires: 
Required-by: wtforms-validators, Flask-WTF 

※ここで存在しなければモジュールをインストール(pip install Flask-WTF)してください。

ソースにLocationのパスを通す

sample.py
import sys
sys.path.append("/Users/XXX/.pyenv/versions/3.7.5/lib/python3.7/site-packages")

これで解決しました。

参考

29
26
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
29
26