1
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.

【Python】ImportError: No module named ~と表示される

Posted at

事象

import schedule
・・・
・・・
    schedule.run_pending()

として「schedule」モジュールを実行しようとしたところ、エラーが表示された。

ImportError: No module named 'schedule'

解決方法

まず「schedule」モジュールがインストールされていることを確認する。

pip show schedule
Name: schedule
Version: 1.0.0
Summary: Job scheduling for humans.
Home-page: https://github.com/dbader/schedule
Author: Daniel Bader
Author-email: mail@dbader.org
License: MIT
Location: c:\users\***\anaconda3\lib\site-packages
Requires:
Required-by:

インストールされていることが分かったので、
LocationでインストールされているPATHを確認。

モジュール検索パスに上記PATHが入っているか確認するために、
Pythonの対話モードを起動し、sys.pathを表示する。

Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>> print(sys.path)

['','C:\\Users\\***\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\***\\Anaconda3\\lib\\site-packages\\Pythonwin']

どうやら入っていないよう。以下コマンドで追加してあげる。

sys.path.append('c:\\users\\***\\anaconda3\\lib\\site-packages')

もう一度実行したらエラーが解消された!

1
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
1
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?