9

我正在学习如何使用 gitstats 通过 git 创建报告。所以我下载并安装了 Git-1.8.1.2-preview20130201.exe , python-2.6.2.msi , gp463-win32-setup.exe(gnuplot) 并克隆了 gitstats

来自http://gitstats.com/。我还将我的 git、python、gnuplot、gitstats 添加到我的 PATH 中。然后我自己用“Git Bash”创建了一个名为 repo1 的存储库。但是当我输入命令来创建

报告 repo1,它会输出如下错误:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Users\Dynamsoft220\Desktop>e:
E:\>cd Jeremy\Git\gitstats
E:\Jeremy\Git\gitstats>python gitstats e:\Jeremy\Git\repo1 e:\Jeremy\Git\report
[0.08100] >> gnuplot --version
Output path: e:\Jeremy\Git\report
Git path: e:\Jeremy\Git\repo1
Collecting data...
[0.12600] >> git shortlog -s HEAD | wc -l
[0.08300] >> git show-ref --tags
[0.18100] >> git rev-list --pretty=format:"%at %ai %aN <%aE>" HEAD | grep -v ^co
mmit
[0.09300] >> git rev-list --pretty=format:"%at %T" HEAD | grep -v ^commit
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python26\lib\multiprocessing\forking.py", line 341, in main
    prepare(preparation_data)
  File "D:\Python26\lib\multiprocessing\forking.py", line 450, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named gitstats

我真的不知道如何解决这个错误。其实我以为可能是因为软件版本太晚了,但似乎不是!对于大多数人来说,这似乎太简单了,无法讨论

TT,所以我找不到很多关于它的文章。任何建议将不胜感激!谢谢~

4

3 回答 3

11

我在让 gitstats 在 Windows 上运行时也遇到了问题。这很棘手,因为看起来一切正常,但它只是不起作用!

这里有一些对我有帮助的调整。首先,我确保 PYTHON_PATH 设置正确并将其添加到路径中:

C:\> set PYTHON_PATH=C:\Python27;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk
C:\> set PATH=%PATH%;%PYTHON_PATH%

接下来,我将 gitstats 添加到路径中,因为,为什么不在这一点上:

C:\> set PATH=%PATH%;c:\projects\gitstats

最后,将* 重命名gitstatsgitstats.py

C:\> cd projects\gitstats
C:\> ren gitstats gitstats.py

* github 上的问题日志中提到了重命名,并由@danio 解决:https ://github.com/hoxu/gitstats/issues/34

于 2015-04-01T06:46:02.707 回答
0

您必须gitstat在 PYTHON_PATH 中添加该文件夹。

有关如何在 Windows 中添加 PYTHON_PATH 的信息,请参阅此答案。 https://stackoverflow.com/a/3701730/1226582

于 2014-02-26T15:03:20.380 回答
0

在 Windows中运行gitstats的稍微更完整的说明:

现在在 git bash 中运行:

如果您还没有下载它:“安装” gitstats

  • git clone git://github.com/hoxu/gitstats.git
  • cd gitstats

现在每次你想运行它时,首先将 Python 2 添加到你的 PATH (前面),以便 gitstats 可以使用它:

  • PYTHON_PATH=/C/Python27:/C/Python27/Lib:/C/Python27/DLLs:/C/Python27/Lib/lib-tk
  • PATH=$PYTHON_PATH:$PATH:"/C/Program Files/gnuplot/bin"
  • python gitstats /C/path/to/repo/to/analyze /C/path/to/output/dir
  • 现在C:\path\to\output\dir\index.html在浏览器中打开
于 2021-07-08T07:11:57.163 回答