Jupyter执行!python命令提示zsh:1: command not found: python问题求助
解决Jupyter中
!python命令找不到的问题 排查路径匹配问题
在Jupyter代码单元中运行以下命令,获取当前环境的Python实际路径:!which python !which python3 import sys print(sys.executable)将报错命令里的
python替换为上述输出的路径,比如sys.executable输出/usr/local/bin/python3.10,则修改命令为:!/usr/local/bin/python3.10 -m spacy init fill-config /Users/atharvasankhe/Files/resumeparse/data/training/base_config.cfg config.cfg也可以直接尝试用
python3替代python:!python3 -m spacy init fill-config /Users/atharvasankhe/Files/resumeparse/data/training/base_config.cfg config.cfg使用当前内核的Python执行(最稳妥)
利用sys.executable调用Jupyter当前内核对应的Python解释器,彻底避免环境差异问题:import sys !{sys.executable} -m spacy init fill-config /Users/atharvasankhe/Files/resumeparse/data/training/base_config.cfg config.cfg检查虚拟环境(若使用)
如果是在虚拟环境中安装的Jupyter,务必在启动Jupyter前激活该虚拟环境,确保shell命令默认使用虚拟环境内的Python。
内容的提问来源于stack exchange,提问作者Atharva Sankhe
相关产品推荐
相关产品推荐

