error installing cmc and linear models python packages in Jupyter. Error: "& was unexpected at this time."

error installing cmc and linear models python packages in Jupyter. Error: "& was unexpected at this time."

当我在 Jupyter 中安装 python 包时,我总是遇到错误。

即使在重新启动内核之后,我仍然收到“& 此时是意外的”。错误,无法从 package.Any 想法调用函数如何解决这个问题?

!pip install cmc
pip install linearmodels

发生错误的原因可能是您的 Jupyter 运行了“错误的”终端(例如,sh 而不是 bash).试试“细胞魔法”,如果我的怀疑是正确的,它应该会有所帮助:

%%bash
pip install cmc

更新:这就是最终允许我在 jupyter 中下载 cmc 和其他包的原因。还需要确保该文件位于您的工作目录中。如果其他人在 jupyter 中安装时遇到问题,本文也很有帮助: http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/

from IPython.core.magic import register_line_magic

@register_line_magic
def pip(args):
    """Use pip from the current kernel"""
    from pip import main
    main(args.split())

%pip install cmc