V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
oldbird
V2EX  ›  Python

命令行单步运行可以,脚本运行报错是什么原因

  •  
  •   oldbird · 2021-01-08 16:51:34 +08:00 · 1479 次点击
    这是一个创建于 1197 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在 IDE 的 shell 里单步运行 import A 可以,

    在 IDE 的编辑器里直接运行 py 文件,或者在 CMD 里单步运行 import A 报错,

    提示是该模块的 init 文件中 有一行 from A.b import *

    SystemError:initialization of b raised unreported exception

    init.py 同目录下有 b.pyd 文件

    2 条回复    2021-01-08 22:29:28 +08:00
    dorothyREN
        1
    dorothyREN  
       2021-01-08 17:21:47 +08:00
    是不是有同名的。。
    nthhdy
        2
    nthhdy  
       2021-01-08 22:29:28 +08:00
    有可能是 b 中有一些额外的启动条件,比如对环境变量、启动路径有要求。可能不是 import 机制的问题,因为报的不是 ImportError,所以不是找不到模块、包的问题。可以想办法找找 b 的源码,看看里面做了什么。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2759 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:43 · PVG 20:43 · LAX 05:43 · JFK 08:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.