ImportError: No module named git after reformatting laptop
ImportError: No module named git after reformatting laptop
我的笔记本电脑已经格式化并安装了新的 OS,从那以后我得到这个错误:
导入错误:没有名为 git
的模块
这是指 python 代码,它只是导入 git。
我的笔记本电脑格式化前 git 的位置:/usr/local/bin/git
笔记本电脑格式化后git的位置:/usr/bin/git
如何/更改我的 python 代码以引用正确的路径?
git
模块与 git
命令行可执行文件不同。它们恰好具有相同的名称并涵盖相关任务,但它们是不同的软件包。
我假设您的代码导入的 git
模块是由 GitPython project. You'll need to install that project, see their installation instructions:
# pip install gitpython
在我的cas中,我安装了pythong2-git,解决了我的问题
sudo apt-get install python3-git
在我的情况下 apt install python-git 修复了问题。
你可以试试这个。
GitPython 的 git 存储库在 GitHub 上可用,可在以下位置浏览:
https://github.com/gitpython-developers/GitPython
并使用克隆:
$ git 克隆 https://github.com/gitpython-developers/GitPython git-python
初始化所有子模块以获取所需的依赖项:
$ cd git-python
$ git 子模块更新 --init --recursive
在 Centos7 中(可能在 Redhat 系统中也可以),如果您使用 Python2.7 :
sudo yum install epel-release
sudo yum install python-pip
sudo yum install GitPython.noarch
以上命令是在Python2
中安装gitpython
我的笔记本电脑已经格式化并安装了新的 OS,从那以后我得到这个错误: 导入错误:没有名为 git
的模块这是指 python 代码,它只是导入 git。
我的笔记本电脑格式化前 git 的位置:/usr/local/bin/git 笔记本电脑格式化后git的位置:/usr/bin/git
如何/更改我的 python 代码以引用正确的路径?
git
模块与 git
命令行可执行文件不同。它们恰好具有相同的名称并涵盖相关任务,但它们是不同的软件包。
我假设您的代码导入的 git
模块是由 GitPython project. You'll need to install that project, see their installation instructions:
# pip install gitpython
在我的cas中,我安装了pythong2-git,解决了我的问题
sudo apt-get install python3-git
在我的情况下 apt install python-git 修复了问题。
你可以试试这个。
GitPython 的 git 存储库在 GitHub 上可用,可在以下位置浏览:
https://github.com/gitpython-developers/GitPython 并使用克隆:
$ git 克隆 https://github.com/gitpython-developers/GitPython git-python
初始化所有子模块以获取所需的依赖项:
$ cd git-python $ git 子模块更新 --init --recursive
在 Centos7 中(可能在 Redhat 系统中也可以),如果您使用 Python2.7 :
sudo yum install epel-release
sudo yum install python-pip
sudo yum install GitPython.noarch
以上命令是在Python2
中安装gitpython