As we all know we can use !<command>
to ensure the cell runs a terminal command.
However if we usepip install lxml
it installs lxml
in the root python kernel and not the kernel environment that we mention in Jupyter.
With !
command in jupyter notebook
, any way to use the python virtual env to install the packages?
if os.name=='posix':
!pip3 install wget
import wget
This was the code I was trying to run but it installs in python-base
and not venv
selected in Jupyter notebook
CodePudding user response:
In recent versions of Jupyter you can use the magic %pip
command that will target the current kernel rather than the Python installation that is running the notebook.
if os.name=='posix':
%pip install wget
import wget
CodePudding user response:
- Check your env used by the notebook check venv on. Also, your can check your env list ref: In which conda environment is Jupyter executing?
- Test import after restarting your
python-base
.