Installing a pip package from within a Jupyter Notebook not working

前端 未结 10 2062
无人及你
无人及你 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:35
    ! pip install --user <package>
    

    The ! tells the notebook to execute the cell as a shell command.

    0 讨论(0)
  • 2020-12-02 09:36
    %pip install fedex    #fedex = package name
    

    in 2019.

    In older versions of conda:

    import sys
    !{sys.executable} -m pip install fedex     #fedex = package name
    

    *note - you do need to import sys

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

    The problem is that pyarrow is saved by pip into dist-packages (in your case /usr/local/lib/python2.7/dist-packages). This path is skipped by Jupyter so pip won't help.

    As a solution I suggest adding in the first block

    import sys
    sys.path.append('/usr/local/lib/python2.7/dist-packages')
    

    or whatever is path or python version. In case of Python 3.5 this is

    import sys
    sys.path.append("/usr/local/lib/python3.5/dist-packages")
    
    0 讨论(0)
  • 2020-12-02 09:38

    Using pip2 worked for me:

    !pip2 install geocoder
    ...
    import geocoder
    g = geocoder.google('Mountain View, CA')
    g.latlng
    [37.3860517, -122.0838511]
    
    0 讨论(0)
  • 2020-12-02 09:42

    This worked for me in Jupyter nOtebook /Mac Platform /Python 3 :

    import sys
    !{sys.executable} -m pip install -r requirements.txt
    
    0 讨论(0)
  • 2020-12-02 09:44

    In jupyter notebook under python 3.6, the following line works:

    !source activate py36;pip install <...>
    
    0 讨论(0)
提交回复
热议问题