PyParsing 不导入 Word 或字母
PyParsing not importing Word or alphas
OS X 10.9.5,Python 3.4,PyParsing 2.0.3,PyCharm 4.0 CE
我使用 easy_install 安装了 PyParsing,并在我的 PyCharm 项目解释器面板中看到它与其他 Python 3.4 包一起存在。
我尝试了运行 PyParsing wiki 中的以下"Hello World!" 脚本:
from pyparsing import Word, alphas
greet = Word( alphas ) + "," + Word( alphas ) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseString( hello ))
我收到以下错误:
File "/Users/..../pyparsing.py", line 1, in <module>
from pyparsing import Word, alphas
ImportError: cannot import name 'Word'
PyCharm 代码 window 消息说,"This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."
我曾尝试使用谷歌搜索类似的情况和解决方案,但遇到了僵局。
你从来没有调用过你的程序文件 "pyparsing.py" 是吗?如果是这样,这将混淆 python(它将尝试从自身导入 Word。尝试将名称更改为无害的名称,例如 temp1.py
编辑
通常避免使用可能会使 python 解释器和您混淆的文件和变量名称。
OS X 10.9.5,Python 3.4,PyParsing 2.0.3,PyCharm 4.0 CE
我使用 easy_install 安装了 PyParsing,并在我的 PyCharm 项目解释器面板中看到它与其他 Python 3.4 包一起存在。
我尝试了运行 PyParsing wiki 中的以下"Hello World!" 脚本:
from pyparsing import Word, alphas
greet = Word( alphas ) + "," + Word( alphas ) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseString( hello ))
我收到以下错误:
File "/Users/..../pyparsing.py", line 1, in <module>
from pyparsing import Word, alphas
ImportError: cannot import name 'Word'
PyCharm 代码 window 消息说,"This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."
我曾尝试使用谷歌搜索类似的情况和解决方案,但遇到了僵局。
你从来没有调用过你的程序文件 "pyparsing.py" 是吗?如果是这样,这将混淆 python(它将尝试从自身导入 Word。尝试将名称更改为无害的名称,例如 temp1.py
编辑 通常避免使用可能会使 python 解释器和您混淆的文件和变量名称。