【发布时间】:2015-06-08 22:44:10
【问题描述】:
简短的问题描述: 当我尝试通过 PyCharm 使用 paster 运行/调试 pylons 项目时,它找不到正在导入的 Thrift ttypes 模块。如果我手动运行 paste 效果很好。错误信息只是:
File "/myproj/lib/timetools/__init__.py", line 13, in <module>
import lib.thrift.common.international.ttypes as international_ttypes
port Error: No module named internation.ttypes
详细说明: 我是第一次尝试 PyCharm。我已经在 Mac OSX Yosemite 上下载并安装了它,并将它指向项目目录,并且我已经配置了虚拟环境(python 解释器)。
项目结构(与此问题相关的部分)如下所示:
/myproj/lib/timetools/__init__.py
/myproj/lib/thrift/common/international.thrift
/myproj/build/py/lib/python2.6/site-packages/lib/thrift/common/international/ttypes.pyc
/myproj/mypylons/config/development.ini
我的虚拟环境设置为 /myproj/build/py/bin/python。
如果我进入我的项目根目录并运行我的激活脚本以使用我的虚拟环境,我可以成功运行:
paster serve config:/myproj/mypylons/config/development.ini
服务器启动并在适当的端口上响应。
我配置 PyCharm 以运行 pylons 的方式尝试执行以下操作:
/myproj/build/py/bin/python "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --multiproc --client 127.0.0.1 --port 53432 --file /myproj/build/py/bin/paster serve config:/myproj/mypylons/config/development.ini
我得到了上面的错误。 PyCharm 似乎无法在我的构建目录中找到 international/ttypes.pyc 文件,即使它包含在项目中。我尝试将工作目录设置为 /myproj/build/py/lib/python2.6/site-packages 但这没有帮助。
请注意,当我查看 Project Interpreter 配置时,我确实看到 Thrift 包的路径为 /myproj/build/py/lib/python2.6/site-packages。
救命!
【问题讨论】:
-
你检查过 PYTHONPATH 吗?
-
@SeverinPappadeux 我不确定我应该在 PYTHONPATH 中寻找什么。 site-packages 目录在我的项目根目录下,所以我不知道为什么它找不到 ttypes.pyc 文件。