在IDE中提示找不到thrift相关的模块

本文详细记录了在OSX系统下使用IntelliJ IDEA进行Python开发时,遇到Thrift模块无法导入的问题及解决方案。作者通过检查Python库路径、手动安装Thrift组件并调整IDEA配置,最终成功解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本人为OS X用的IDEA,在输入from thrift...并没有任何提示,也不能手动导入模块,已经在IDEA里下载了Python和Thrift的插件,本机也安装好了Python和Thrift。

输入一段代码查到引用Python的目录

from distutils.sysconfig import get_python_lib

print(get_python_lib())

我这里显示为/Library/Python/2.7/site-packages,进入文件夹后,发现并没有任何关于Thrift的相关文件。

进入目录/usr/local/lib/python2.7/site-packages中,发现也没有下载Python的thrift组件,输入

easy_install -i https://pypi.python.org/simple/ thrift

下载安装,安装于/usr/local/lib/python2.7/site-packages下,输入

sudo cp -r /usr/local/lib/python2.7/site-packages/thrift-0.11.0-py2.7-macosx-10.12-x86_64.egg/thrift /Library/Python/2.7/site-packages/

将下载的thritf的模块复制到引用目录。

启动IDEA,不报错了,OK。

为什么pycharm控制台不能使用且会出现以下内容E:\python-3.12.7-amd64\python.exe "D:\python\kong\PyCharm 2020.3\plugins\python\helpers\pydev\pydevconsole.py" --mode=client --port=51163 ------------------------------------------------------------------------------- pydev debugger: CRITICAL WARNING: This version of python seems to be incorrectly compiled (internal generated filenames are not absolute) pydev debugger: The debugger may still function, but it will work slower and may miss breakpoints. pydev debugger: Related bug: http://bugs.python.org/issue1666807 ------------------------------------------------------------------------------- Traceback (most recent call last): File "D:\python\kong\PyCharm 2020.3\plugins\python\helpers\pydev\pydevconsole.py", line 33, in <module> from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface File "D:\python\kong\PyCharm 2020.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_console_utils.py", line 12, in <module> from _pydevd_bundle import pydevd_thrift File "D:\python\kong\PyCharm 2020.3\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 20, in <module> from pydev_console.pydev_protocol import DebugValue, GetArrayResponse, ArrayData, ArrayHeaders, ColHeader, RowHeader, \ File "D:\python\kong\PyCharm 2020.3\plugins\python\helpers\pydev\pydev_console\pydev_protocol.py", line 6, in <module> _console_thrift = _shaded_thriftpy.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), "console.thrift"), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\kong\PyCharm 2020.3\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\parser\__init__.py", line 29, in load thrift = parse(path, module_name, include_dirs=include_dirs, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\kong\PyCharm 2020.3\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\parser\parse
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值