【问题标题】:svn.remote.RemoteClient.info: FileNotFoundError: [WinError 2] The system cannot find the file specifiedsvn.remote.RemoteClient.info: FileNotFoundError: [WinError 2] 系统找不到指定的文件
【发布时间】:2018-05-21 21:04:58
【问题描述】:

我正在尝试连接 SVN 远程客户端并在 Windows 中使用以下 python 代码获取最新提交的修订:

r = svn.remote.RemoteClient(svnPath)
revNum = str(r.info().get("commit#revision"))

我收到以下错误:

in \n revNum = str(r.info().get("commit#revision"))\n', ' 文件“C:\程序 文件\Python36\lib\site-packages\svn-0.3.45-py3.6.egg\svn\common.py", 第 75 行,在 info\n do_combine=True)\n', ' File "C:\Program 文件\Python36\lib\site-packages\svn-0.3.45-py3.6.egg\svn\common.py", 第 54 行,在 run_command\n 中返回 self.external_command(cmd, environment=self.env, **kwargs)\n', ' 文件 "C:\Program 文件\Python36\lib\site-packages\svn-0.3.45-py3.6.egg\svn\common_base.py", 第 25 行,在 external_command\n env=env)\n', ' File "C:\Program Files\Python36\lib\subprocess.py",第 709 行,在 __init 中\n
restore_signals, start_new_session)\n', ' 文件 "C:\Program Files\Python36\lib\subprocess.py",第 997 行,在 _execute_child\n
startupinfo)\n']: [WinError 2] 系统 找不到指定的文件

我尝试打印“svnpath”和“r”以确保它正确无误。我得到了“svnpath”和< SVN(REMOTE) remote_path>r”的正确远程服务器路径(比如说“remote_path”)。

远程 SVN 需要凭据(UID 和 PWD)才能访问。但是,我使用此脚本运行的机器已经使用正确的凭据设置了 SVN。 我是否仍需要在 python 脚本中指定显式凭据才能访问?如果是,那怎么办?或者我需要任何额外的 SVN python 包吗?

请帮忙...

【问题讨论】:

    标签: python svn


    【解决方案1】:

    我遇到了同样的错误,并通过安装 SVN 命令行并将其路径添加到 PATH 环境变量来修复它。

    如果您使用的是 Windows,则可以在安装 Tortoise SVN 时安装命令行可执行文件,但默认情况下不选中相应的选项(请参阅ccpizza's answer)。

    【讨论】:

      【解决方案2】:

      到那时您可能已经解决了您的问题,但查看代码可能会有所帮助。

      RemoteClient 类继承自 CommonClient,其开头如下:

      class CommonClient(svn.common_base.CommonBase):
          def __init__(self, url_or_path, type_, username=None, password=None, 
                       svn_filepath='svn', trust_cert=None, env={}, *args, **kwargs):
              super(CommonClient, self).__init__(*args, **kwargs)
         ...
      

      因此,以下应该有效:

      import svn.remote
      
      url = "http://server.com:8080/svn/SuperRepo/branches/tool-r20"
      
      client = svn.remote.RemoteClient(url, username="toto", password="SuperPassword")
      print(client.info())
      

      【讨论】:

      • 不适合我。 error , " [WinError 2] 系统找不到指定的文件"
      • 只是再次检查:您确定路径存在吗?
      • 路径存在。我可以通过 Tortoise svn 客户端结帐。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-02
      • 1970-01-01
      • 2017-08-01
      • 2019-07-29
      • 1970-01-01
      相关资源
      最近更新 更多