pythonエラーNo module named XXX共通解決方法

1326 ワード

一つの問題現象
D:\Python27\python.exe E:/Python/MySQLControler/Main/Main.py
Traceback (most recent call last):
  File "E:/Python/MySQLControler/Main/Main.py", line 17, in 
    from Notice import MyFrame3
ImportError: No module named Notice

Process finished with exit code 1

二解決方法
1 D:Python 27Libsite-packagesフォルダへ
2新しいファイルmypkpath.pth
3ファイルに追加
E:\Python\MySQLControler\Notice
4有効かどうかを確認する方法
E:\Python\MySQLControler>python
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'E:\\Python\\MySQLControler', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'D:\\Python27\\DLLs', 'D:\\Python27\\lib', 'D:\\Python27\\lib\\plat-win', 'D:\\Python27\\lib\\lib-tk', 'D:\\Python27', 'C:\\Users\\
cakin\\AppData\\Roaming\\Python\\Python27\\site-packages', 'D:\\Python27\\lib\\site-packages', 'D:\\Python27\\lib\\site-packages\\pip-9.0.1-py2.7.egg', 'E:\\Python\\MySQLControler\\WriteAndReadFile', 'E:\\
Python\\MySQLControler\\Notice']