【问题标题】:"git@github.com: Permission denied (publickey)" when installing the dependencies from xero-python-oauth2-starter-master从 xero-python-oauth2-starter-master 安装依赖项时“git@github.com: Permission denied (publickey)”
【发布时间】:2020-08-06 11:25:37
【问题描述】:

我正在尝试使用 xero-python-oauth2-starter-master,但我无法通过第一步! 我在 Windows 上,我已经安装了 python 3.8、Visual Studio Code(我也尝试过使用 Anaconda 套装)和最新的 Git。

当我尝试在 requirments.txt 上运行依赖项时,我收到错误 Permission denied。请看下面这是来自使用 Windows PowerShell(也尝试从 cmd、Anaconda PowerShell 和 Anaconda CMD)

PS C:\Users\m.*\OneDrive\Python\xero-python-oauth2-starter-master> pip install -r requirements.txt
Collecting flask
  Using cached Flask-1.1.2-py2.py3-none-any.whl (94 kB)
Collecting Flask-Session
  Cloning https://github.com/SqrtMinusOne/flask-session.git (to revision 560d00f1a84a9924d788a4f4e1ef35c5cf94c76d) to c:\users\m.*\appdata\local\temp\pip-install-d803d7fn\flask-session
  Running command git clone -q https://github.com/SqrtMinusOne/flask-session.git 'C:\Users\m.*\AppData\Local\Temp\pip-install-d803d7fn\Flask-Session'
  Running command git checkout -q 560d00f1a84a9924d788a4f4e1ef35c5cf94c76d
  Running command git submodule update --init --recursive -q
  git@github.com: Permission denied (publickey).
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.
  fatal: clone of 'git@github.com:mitsuhiko/flask-sphinx-themes.git' into submodule path 'C:/Users/m.*/AppData/Local/Temp/pip-install-d803d7fn/Flask-Session/docs/_themes' failed
  Failed to clone 'docs/_themes'. Retry scheduled
  git@github.com: Permission denied (publickey).
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.
  fatal: clone of 'git@github.com:mitsuhiko/flask-sphinx-themes.git' into submodule path 'C:/Users/m.*/AppData/Local/Temp/pip-install-d803d7fn/Flask-Session/docs/_themes' failed
  Failed to clone 'docs/_themes' a second time, aborting
ERROR: Command errored out with exit status 1: git submodule update --init --recursive -q Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 20.2.1 is available.
You should consider upgrading via the 'c:\users\m.*\appdata\local\programs\python\python38-32\python.exe -m pip install --upgrade pip' command.

requirments.txt的内容

flask
# Werkzeug<1.0  # flask-session not compatible
# see https://github.com/fengsp/flask-session/pull/114
# using patched version of flask-session
git+https://github.com/SqrtMinusOne/flask-session.git@560d00f1a84a9924d788a4f4e1ef35c5cf94c76d#egg=Flask-Session
# Werkzeug<1.0  # flask-oauthlib not compatible
# using patched version of flask-oauthlib
git+https://github.com/ageis/flask-oauthlib.git@c5ea3ace957ceeeeab3cfb6556f32685ff292eab#egg=Flask-OAuthlib

# Use development version of xero-python
#git+ssh://git@github.com/xero-github/xero-python.git@020f780b4e2b48cb33746ae19ddab9fdf128e626#egg=xero-python
xero-python==0.5.1

【问题讨论】:

  • 编辑requirements.txt,将git@github.com:的所有条目更改为https://github.com/应该更正权限问题,或者简单地将git+ssh://git@的任何用法修改为git+http://
  • 我没有git@github.com:git+ssh://git@
  • 你没有,但是列出的依赖项之一,flask-session,通过它的.gitmodules
  • 我不明白我必须做什么
  • 因此,由于这种依赖性,它继续给出错误,所以我在 ~/.gitconfig [url "https://"] insteadOf = ssh://git@ insteadOf = git@ [url "https://github.com/mitsuhiko/flask-sphinx-themes.git"] insteadOf = git@github.com:mitsuhiko/flask-sphinx-themes.git 上添加了以下内容,所以它不是真正的解决方案,但它可以工作

标签: python github pip xero-api


【解决方案1】:

试试git config url.&lt;URL&gt;.insteadOf:

git config --global url."https://".insteadOf "git@"
git config --global url."https://".insteadOf "ssh://git@"

这样每个git@ssh://git@ 都将替换为https://

更新

git config --global url."https://github.com/".insteadOf "git@github.com:"

git config --global url."https://github.com/mitsuhiko/flask-sphinx-themes.git".insteadOf "git@github.com:mitsuhiko/flask-sphinx-themes.git"

【讨论】:

  • 我这样做了,现在我得到了这个错误fatal: unable to access 'https://github.com:mitsuhiko/flask-sphinx-themes.git/': URL using bad/illegal format or missing URL这是git子模块中的原始git@github.com:mitsuhiko/flask-sphinx-themes.git
  • 我刚刚将整个内容替换为 .gitconfig 中的正确格式,它工作正常。谢谢
  • 糟糕,抱歉,必须是 https://github.com/mitsuhiko/flask-sphinx-themes.git。添加到答案中。
【解决方案2】:

您可以通过为您的 github 配置文件设置 SSH 密钥来解决此问题。

请检查您的 SSH 密钥是否已为您的 github 配置文件设置? https://github.com/settings/keys

我们在当前版本的 Flask-Session 中遇到了一些问题,必须指向特定的提交并将该代码下载到我们的项目中。但为了做到这一点,您需要配置 SSH 密钥。

https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh

【讨论】:

    猜你喜欢
    • 2021-09-23
    • 1970-01-01
    • 2013-10-13
    • 2019-01-25
    • 2016-10-04
    • 2016-01-05
    • 2011-02-08
    相关资源
    最近更新 更多