推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
wuliaoshixia
V2EX  ›  Python

Windows 下 cmd 执行 Python ,报 ImportError: No module named 是啥原因?

  •  
  •   wuliaoshixia · Apr 8, 2019 · 3534 views
    This topic created in 2766 days ago, the information mentioned may be changed or developed.
    RT,在目录下都加了__init__.py 文件,然后 python 都写了入口方法:
    if __name__ == '__main__':
    start_package()
    5 replies  •  2019-04-15 10:46:49 +08:00
    Loner233
    Loner233
    Apr 8, 2019 via Android
    1
    你 import 的东西可能没有装
    wsh1108
    wsh1108
    Apr 8, 2019
    2
    刚刚我也遇到了<br>
    这样可以<br>
    from config import *<br>
    这样不行<br>
    from app.config import *<br>
    Northxw
    Northxw
    Apr 8, 2019
    3
    将当前项目的 path 添加到 Python 解释器的搜索路径,具体操作自行百度。如果嫌麻烦,可以将绝对路径添加到 from 中,或者 source root。
    Qzier
    Qzier
    Apr 9, 2019 via iPhone
    4
    把你的目录结构发出来
    wuliaoshixia
    wuliaoshixia
    OP
    Apr 15, 2019
    5
    最后排查,是路径错了,pycharm ide 里面执行路径默认是项目根目录,cmd 命令行执行路径是 cmd 的当前路径
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3029 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:35 · PVG 19:35 · LAX 03:35 · JFK 06:35
    ♥ Do have faith in what you're doing.