python - 通过 Jupyter notebook 从 GitHub 安装模块

标签 python github jupyter-notebook

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

我正在使用 Jupyter Notebook 并尝试安装此模块:

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 安装路径的 session 中运行 Jupyter Notebook。

check out pip issue 2109 :

在我的例子中,问题是我在 Windows 的路径环境中定义了 git 的路径。

the function find_command declared in pip.util fails in handle paths with quote, like:

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

when it appends the git.exe filename to check its existence it keeps the " symbol and the check fails.

这应该在最新版本的 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 installation error “No such file or directory: setup.py”,并仔细检查您的 Python 版本:pip 适用于 python 2。pip3 适用于 python 3 .

关于python - 通过 Jupyter notebook 从 GitHub 安装模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44873473/

相关文章:

python - 如何自动编译python/c扩展?

python - 用python networkx计算图的入度中心化

ruby - 使用 Chef 从 Github 存储库安装 Ruby gem?

github - GitHub 用户如何查看更改历史以发表评论?

matplotlib - 如何获取 Python 脚本文件名作为从 Jupyter 正确显示的绘图的标题?

使用 Pyinstaller 的 Python 子进程 Popen

python - 下载适用于 Pycharm 的 OpenCV

git - Visual Studio /GIT : No tracked remote branch

python - 从 Jupyter notebook 中删除空行

python - 在开始使用 ipynb 之前,如何编写 shell 脚本来重新启动 jupyter 服务器