I frequently refer to this for personal use:
https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/

During workshops, I ask the learner to save the notebook, close Jupyter,
install on the Terminal (conda if possible), and re-open Jupyter. Sometimes
I ask them to open a Python shell in the Terminal to see if the imports now
work (this can be faster than waiting for Jupyter to load...)

Kunal

On Wed, Feb 12, 2020 at 3:58 AM Pariksheet Nanda <[email protected]>
wrote:

> Hi folks,
>
> I was helping at a Python workshop workshop yesterday and in general I see
> learners launch the Anaconda Jupyter notebook from the Anaconda GUI instead
> of the terminal.
>
> One such user on Mac OSX had launched the notebook from the Anaconda GUI
> but had import errors.  However, if I had him install the packages from
> inside the notebook using "! pip install pandas", the installation
> succeeded but the import errors continued.
>
> This was a little surprising, because that workaround succeeded in the
> past.  I'm assuming that the shell bang pip command inside the cell invokes
> pip associated with the running python's PATH, but maybe that's a false
> assumption and there is a more sensible to install packages for the running
> notebook python version.
>
> It's also possible that the Anaconda GUI had selected a virtual
> environment and that pip installed the package globally instead of into the
> environment.
>
> Has anyone run into something similar and what is the correct way you
> would go about installing a package from a running notebook?  Unfortunately
> I'm mostly familiar with pip / pipenv instead of conda and don't often use
> notebooks in my work.
>
> I know that I could have also had the user not use the Anaconda GUI and
> run the jupyter notebook from the terminal, but in the past I've also
> encountered situations where users have multiple Anaconda and Miniconda
> installations where one has to mangle the ~/.bash_profile and was therefore
> hesitant to go down that road and opted to instead work within the context
> of using the Anaconda GUI that the user is already familiar with.
>
> Pariksheet
> *The Carpentries <https://carpentries.topicbox.com/latest>* / discuss /
> see discussions <https://carpentries.topicbox.com/groups/discuss> +
> participants <https://carpentries.topicbox.com/groups/discuss/members> + 
> delivery
> options <https://carpentries.topicbox.com/groups/discuss/subscription>
> Permalink
> <https://carpentries.topicbox.com/groups/discuss/T72d9652a490be7d3-Me32abccb4262ecc1eb389d93>
>

------------------------------------------
The Carpentries: discuss
Permalink: 
https://carpentries.topicbox.com/groups/discuss/T72d9652a490be7d3-M54c0adf1d0b6371c9b6001ea
Delivery options: https://carpentries.topicbox.com/groups/discuss/subscription

Reply via email to