30
27

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 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")

これで解決しました。

##参考
https://web.plus-idea.net/2017/05/python-import-error-no-module-name/

30
27
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
30
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?