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

Viewed 61

I keep getting an error when I install python packages in Jupyter.

Even after restarting the kernel, I still get the "& was unexpected at this time." error and cannot call functions from the package.Any idea how to resolve this?

!pip install cmc
pip install linearmodels

error message

2 Answers

It's possible that the error occurs because your Jupyter runs a "wrong" terminal (e.g., sh instead of bash). Try a "cell magic", it should help if my suspicion is correct:

%%bash
pip install cmc

Update: This is what ended up allowing me to download cmc and other packages in jupyter. Also need to make sure the file is on your working directory. This article is helpful as well if others are having issue installing in 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
Related