通过Jupyter Notebook从GitHub安装模块


问题内容

我第一次尝试从GitHub安装某些东西,但是在这里和Google上搜索后找不到简单的解决方案。

我正在使用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。

我究竟做错了什么 ?

谢谢!


问题答案:

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

查看pip问题2109

就我而言,问题是在Windows的路径环境中定义git路径的方式。

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

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

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

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


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

关于此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安装错误”,没有此类文件或目录:setup.py
”,然后仔细检查您的Python版本:pip适用于python2。pip3适用于python 3。