当前位置:   article > 正文

python import报错

cannot load imports from non-existent stub
  1. 导入路径
    import sys
    sys.path
    ['',
    '../',
    '/Users/delron/.virtualenv/py3/bin',
    '/Users/delron/.virtualenv/py3/lib/python36.zip',
    '/Users/delron/.virtualenv/py3/lib/python3.6',
    '/Users/delron/.virtualenv/py3/lib/python3.6/lib-dynload',
    '/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
    '/Users/delron/.virtualenv/py3/lib/python3.6/site-packages',
    '/Users/delron/.virtualenv/py3/lib/python3.6/site-packages/IPython/extensions',
    '/Users/delron/.ipython',
    ]

sys.path.append("../")
sys.path.insert(1, "../")

2.导入时 python解释器会维护一个包的副本 (缓存) 在内存中

  1. 让新模块生效的方式:
  2. 1. 重新启动
  3. 2. imp.reload()

3.导入同级或上级目录的文件可在模块前加上相对路径

转载于:https://www.cnblogs.com/LSJOP/p/7508091.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/945262
推荐阅读
相关标签
  

闽ICP备14008679号