通过Jupyter笔记本从GitHub安装模块

时间:2017-07-02 17:35:04

标签: python github jupyter-notebook

我第一次尝试从GitHub安装一些东西,但在搜索此处和谷歌后无法找到一个简单的解决方案。

我正在使用Jupyter笔记本并尝试安装此模块:

https://github.com/Expt-David/NumSchrodingerEq

我试图在笔记本中写下这个:

!pip install git+git://github.com/Expt-David/NumSchrodingerEq.git

但我收到以下错误:

Collecting git+git://github.com/Expt-David/NumSchrodingerEq.git
  Cloning git://github.com/Expt-David/NumSchrodingerEq.git to c:\users\greatg~1\appdata\local\temp\pip-1w_dpw43-build
  Error [WinError 2] The system cannot find the file specified while executing command git clone -q git://github.com/Expt-David/NumSchrodingerEq.git C:\Users\GREATG~1\AppData\Local\Temp\pip-1w_dpw43-build
Cannot find command 'git'
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

修改

似乎再次安装git并手动删除路径并编辑自己为该问题工作,但现在我得到了:

Collecting git+https://github.com/Expt-David/NumSchrodingerEq.git
  Cloning https://github.com/Expt-David/NumSchrodingerEq.git to c:\users\greatg~1\appdata\local\temp\pip-zpuki8tu-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "d:\anaconda3\lib\tokenize.py", line 454, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\GREATG~1\\AppData\\Local\\Temp\\pip-zpuki8tu-build\\setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\GREATG~1\AppData\Local\Temp\pip-zpuki8tu-build\

我安装并更新了setuptools。

我做错了什么?

谢谢!

1 个答案:

答案 0 :(得分:1)

确保从PATH确实包含Git安装路径的会话中运行Jupyter Notebook。

check out pip issue 2109

在我的情况下,问题是我在Windows上的路径环境中定义了git路径的方式。

  

pip.util中声明的函数find_command在带引号的句柄路径中失败,如:

PATH=...;c:\python27\scripts;"c:\Program Files\git\cmd";C:\Tcl\bin;...
  

当它附加git.exe文件名以检查其存在时,它会保留“符号并且检查失败。

这应该在最新版本的pip中修复,但请再次仔细检查%PATH%

如果仍然失败,请尝试使用简化路径,并将Git安装在没有空格的短PATH中:

关于PATH问题,请键入(在CMD中):

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\Git2.13.2
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

PATH添加到python / pip所需的内容 然后再试一次。

对于第二条错误消息,请考虑“pip installation error “No such file or directory: setup.py”,并仔细检查您的Python版本:pip用于python 2. pip3用于python 3。