• webdiff 安装失败和不支持中文


    webdiff 是一个挺好用的 git 差异对比工具。需要使用:

    pip install webdiff
    

    但是很奇怪,公司的电脑能装上,自己家的电脑装不上。报错如下:

        Complete output (1 lines):
        error in webdiff setup command: "values of 'package_data' dict" must be a list of strings (got 'webdiff/static/*')
        ----------------------------------------
    

    又或者是关于 PyGitHub 的报错。

    解决办法

    下载源码 tar.gz 类型的源码: https://pypi.org/project/webdiff/#files

    解压,在根目录找到 setup.py, 将 'PyGithub==1.25.2' 修改成 'PyGithub~=1.25' (因为 PyGithub 这个包,没有 1.25.2 这个版本,所以找不到版本)

    然后在当前目录下,右键 Git Bash here ,执行 tar -zcvf test.tar.gz * 重新打包

    在此目录下,运行 cmd 目录:pip install test.tar.gz 进行安装,不出意外的话,应该能安装成功。

    不支持中文的解决办法

    webdiff 进行差异对比,如果文件中包含中文,则会显示乱码或者报错,这是因为它默认打开文件的方式不是:utf-8 ,所以找到你的 webdiff 的安装目录:path_of_python\Lib\site-packages\webdiff ,在 app.py 中查找如下这段话:

            contents = open(abs_path).read()
            return Response(contents, mimetype='text/plain')
        except Exception:
            return error('read-error', 'Unable to read %s' % abs_path)
    

    将上面的第一行,添加一个编码:

            contents = open(abs_path, encoding='utf-8').read()   # 仅仅加了一个 编码 而已
            return Response(contents, mimetype='text/plain')
        except Exception:
            return error('read-error', 'Unable to read %s' % abs_path)
    
  • 相关阅读:
    10. Regular Expression Matching
    9. Palindrome Number (考虑负数的情况)
    8. String to Integer (整数的溢出)
    7. Reverse Integer (整数的溢出)
    LeetCode Minimum Size Subarray Sum
    LeetCode Course Schedule II
    Linux 文件缓存 (一)
    LeetCode Tries Prefix Tree
    Linux : lsof 命令
    LeetCode Binary Tree Right Side View
  • 原文地址:https://www.cnblogs.com/wztshine/p/16185029.html
Copyright © 2020-2023  润新知