与Python连接到Webdav

时间:2017-03-31 08:46:33

标签: python webdav

我正在尝试使用webdavclient通过Python在webdav服务器上传文件。我正在使用这个非常简单的脚本。我用Python 2和Linux下载了这个库。 3。

import webdav.client as wc

options = {'webdav_hostname': "https://xxxxxx",
           'webdav_login': "xxx",
            'webdav_password': "xxx"
        }

client = wc.Client(options)
client.upload_sync(remote_path="/storage/test_dir/testfile.txt",
                   local_path="/home/ubuntu/testfile.txt")

我经常遇到这个错误:

    import webdav.client as wc
ImportError: No module named client

虽然

:~ nasiantalla$ pip install webdavclient
Requirement already satisfied: webdavclient in ./Library/Python/2.7/lib/python/site-packages
Requirement already satisfied: argcomplete in ./Library/Python/2.7/lib/python/site-packages (from webdavclient)
Requirement already satisfied: lxml in ./Library/Python/2.7/lib/python/site-packages (from webdavclient)
Requirement already satisfied: pycurl in ./Library/Python/2.7/lib/python/site-packages (from webdavclient)

~ nasiantalla$ pip3 install webdavclient
Requirement already satisfied: webdavclient in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already satisfied: pycurl in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from webdavclient)
Requirement already satisfied: lxml in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from webdavclient)
Requirement already satisfied: argcomplete in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from webdavclient)

有没有人之前使用过这个或有类似的问题? 谢谢!

2 个答案:

答案 0 :(得分:0)

安装

$ sudo apt-get install libxml2-dev libxslt-dev python-dev
$ sudo apt-get install libcurl4-openssl-dev python-pycurl
$ sudo easy_install webdavclient

更新

$ sudo pip install -U webdavclient

答案 1 :(得分:0)

请尝试

从webdav3.client导入客户端

options = {'webdav_hostname':“ https://en.cppreference.com/w/c/language/main_function”, 'webdav_login':“ xxx”, 'webdav_password':“ xxx” }

client =客户端(选项)