python - 如何检查Python中的导入别名冲突?

标签 python python-import

我遇到过一些这样的冲突,如何检查现有大型项目中是否存在类似的导入别名?此导入违反了什么规则?

import os.stat as stat
import stat

stat.S_IWRITE
stat(filename).st_mode

最佳答案

我发现使用 -v 选项运行 python 对于调试 python 导入问题非常有用。例如:

python -v script.py

查看控制台并搜索(find、grep 等,无论您熟悉哪个命令)是否存在导入问题的每个包。您应该能够相当快速地找到导入出错的位置。

关于python - 如何检查Python中的导入别名冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42405184/

相关文章:

python - 在Python中使用套接字的剪刀石头布游戏

python - 在 matplotlib 中缩放轴 3d

python - 缩放(规范化)SPARK Dataframe 中的一列 - Pyspark

python - 为什么这个 django url 没有重定向?

python - 如果我们已经在 python 中导入了 tensorflow,为什么还要从 tensorflow 中导入 keras?

python - 导入错误 : cannot import name 'ImageTK'

python - 在 Python 中,当您在函数内部导入时会发生什么?

python - 错误: unbound method Dragon( ) must be called with Enemy instance as first argument (got Player instance instead)

python - 织物导入错误 : "fab task" vs. "from fabfile import task; task()"

python - __subclasses__ 没有显示任何东西