python报错No module named XXX通用解决方法

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/chengqiuming/article/details/84476039

一 问题现象

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 <module>
    from Notice import MyFrame3
ImportError: No module named Notice

Process finished with exit code 1

二 解决方法

1 进入D:\Python27\Lib\site-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']

 

 

展开阅读全文

没有更多推荐了,返回首页