Installing a pip package from within a Jupyter Notebook not working

前端 未结 10 2075
无人及你
无人及你 2020-12-02 09:24

When I run !pip install geocoder in Jupyter Notebook I get the same output as running pip install geocoder in the terminal but the geocoder package

相关标签:
10条回答
  • 2020-12-02 09:50

    Try using some shell magic: %%sh %%sh pip install geocoder let me know if it works, thanks

    0 讨论(0)
  • 2020-12-02 09:53

    Alternative option : you can also create a bash cell in jupyter using bash kernel and then pip install geocoder. That should work

    0 讨论(0)
  • 2020-12-02 09:55
    conda create -n py27 python=2.7 ipykernel
    

    source activate py27
    

    pip install geocoder
    
    0 讨论(0)
  • 2020-12-02 09:57

    In IPython (jupyter) 7.3 and later, there is a magic %pip and %conda command that will install into the current kernel (rather than into the instance of Python that launched the notebook).

    %pip install geocoder
    

    In earlier versions, you need to use sys to fix the problem like in the answer by FlyingZebra1

    import sys
    !{sys.executable} -m pip install geocoder
    
    0 讨论(0)
提交回复
热议问题