报错信息
pycharm内嵌python控制台报错
**\***\python.exe "**\***/JetBrains/PyCharm Community Edition 2023.2.3/plugins/python-ce/helpers/pydev/pydevconsole.py" --mode=client --host=127.0.0.1 --port=49537
Traceback (most recent call last):
File "**\***\JetBrains\PyCharm Community Edition 2023.2.3\plugins\python-ce\helpers\pydev\pydevconsole.py", line 4, in <module>
from _pydev_bundle._pydev_getopt import gnu_getopt
ModuleNotFoundError: No module named '_pydev_bundle'
无法连接到控制台进程。
进程已结束,退出代码为 1
形成原因
问题发生原因不明,使用python embed版本(zip版本)在pycharm中必定报错(同类型还有使用get-pip.py后依旧pip not found)
根本原因
pycharm的组件模块或者别的什么名字总之就是pycharm应用自身有一些python模块无法被python.exe(或python可执行文件)找到。
解决办法
- 找到缺失组件所在位置(报错提示中有文件路径)
**\***\JetBrains\PyCharm Community Edition 2023.2.3\plugins\python-ce\helpers\pydev\**
- 在
embed版python.exe
目录下,找到并在python***._pth
中添加两行
python312.zip
.
./Lib/site-packages # resolve of pip not found and any exceptions of libary not found
# import for PyCharm console debug
**\***\JetBrains\PyCharm Community Edition 2023.2.3\plugins\python-ce\helpers\third_party\thriftpy
**\***\JetBrains\PyCharm Community Edition 2023.2.3\plugins\python-ce\helpers\pydev
# Uncomment to run site.main() automatically
#import site
其中,**\***
是你pycharm的安装路径。可以从报错信息中直接获取
Traceback (most recent call last): File "**\***\JetBrains\PyCharm Community Edition 2023.2.3\plugins\python-ce\helpers\pydev\pydevconsole.py", line 4, in <module>