在部署cerlery (芹菜)这玩意 ,有个cerlery.py 文件老报错,,,,找不到模块、经过分析以后,
这不是模块冲突了吗
奉劝大家,不要这么干,自己写的程序 名字 ,不要写成与模块同名,还要引入这个模块!!
但是还好有解决方法:
1 说了相当于白说
把自己文件名字更换
2 重点来了
import sys
_cpath_ = sys.path[0] #获取当前路径
sys.path.remove(_cpath_) #删除
from jira import JIRA
sys.path.insert(0, _cpath_) #恢复
sys.path.remove(_cpath_) #删除
这一条可以将path中的第一条删除sys.path.insert(0, _cpath_) #恢复
这一条可以将path恢复成原来的样子
程序总是将上级目录内容定位最高优先级,只要将它暂时屏蔽掉就可以了