自动化测试交流学习群,不定期会有群成员分享一些技巧和工具知识,欢迎加入...
Selenium学习成长群

conda pack环境迁移后jupyterlab kernel python环境找不到解决办法

报错信息

启动 jupyter lab,运行python脚本后界面弹出如下错误:

FileNotFoundError: [Errno 2] No such file or directory: ‘/home/conda/feedstock_root/build_artifacts/ipykernel_1717717528849/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/bin/python’

这是由于运行python时 jupyter kernels中配置的python环境不正确了导致的

修复方法

打开python环境目录,找到 share/jupyter/kernels/python3/kernel.json 文件。

修改文件中 argv 参数对应python环境路径为当你前使用python环境路径

{
 "argv": [
  "/home/conda/feedstock_root/build_artifacts/ipykernel_1719845459717/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": true
 }

比如修改后:

{
 "argv": [
  "/home/tsbc/python3.12/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": true
 }

修改完成后重新启动 jupyter lab即可。

posted @ 2026-02-07 03:46  oO_Ray  阅读(11)  评论(0)    收藏  举报