通过 Jupyter notebook 从 GitHub 安装模块

4

这是我第一次尝试从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
你的系统未安装Git。请安装Git。错误信息为:无法找到命令 'git' - idjaw
在您的系统上安装Hit,如果已经安装,则将其添加到路径中。 - Arpit Solanki
我已经安装了Git桌面版(适用于Windows),但仍然出现错误。我是否应该以某种方式将其导入笔记本电脑? - ValientProcess
1个回答

2
确保您在包含Git安装路径的会话中运行Jupyter Notebook。

并且{{link1:查看pip问题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问题,请在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%

再加上你需要的Python/pip路径到PATH中。
然后再试一次。
对于您的第二个错误信息,请考虑 "pip安装错误“No such file or directory: setup.py",并仔细检查您的Python版本: pip 适用于 Python 2。而 pip3 适用于 Python 3。

@ValientProcess 你的PATH是什么样子?你能在命令行中输入“git version”吗? - VonC
路径没问题(不需要引号),但现在我遇到了另一个错误:“Command "python setup.py egg_info" failed with error code 1 in C:\Users\GREATG~1\AppData\Local\Temp\pip-zpuki8tu-build"。 - ValientProcess
@ValientProcess 好的,我已经编辑了答案,为你提供了一个可供测试的替代方案。(针对你的第一个问题)。 - VonC

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接