推荐学习书目
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 · 3068 views
    This topic created in 2595 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
        1
    Loner233  
       Apr 8, 2019 via Android
    你 import 的东西可能没有装
    wsh1108
        2
    wsh1108  
       Apr 8, 2019
    刚刚我也遇到了<br>
    这样可以<br>
    from config import *<br>
    这样不行<br>
    from app.config import *<br>
    Northxw
        3
    Northxw  
       Apr 8, 2019
    将当前项目的 path 添加到 Python 解释器的搜索路径,具体操作自行百度。如果嫌麻烦,可以将绝对路径添加到 from 中,或者 source root。
    Qzier
        4
    Qzier  
       Apr 9, 2019 via iPhone
    把你的目录结构发出来
    wuliaoshixia
        5
    wuliaoshixia  
    OP
       Apr 15, 2019
    最后排查,是路径错了,pycharm ide 里面执行路径默认是项目根目录,cmd 命令行执行路径是 cmd 的当前路径
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3126 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 03:45 · PVG 11:45 · LAX 20:45 · JFK 23:45
    ♥ Do have faith in what you're doing.