使用Python Upwork 库时遇到问题。它已通过 PIP 安装。
在 ...\site-packages\upwork\ 我创建了 myAuth.py 文件。
到目前为止,该文件的内容是:
apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
secretKey = 'XXXXXXXXXXXXXXXXXX'
import upwork
这是来自 cmd 行的回溯:
C:\Python36-32\Lib\site-packages\upwork>python myAuth.py
Traceback (most recent call last):
File "myAuth.py", line 4, in <module>
import upwork
File "C:\Python36-32\lib\site-packages\upwork\__init__.py", line 23, in <module>
from upwork.client import Client
File "C:\Python36-32\lib\site-packages\upwork\client.py", line 8, in <module>
import urllib3
File "C:\Python36-32\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 11, in <module>
from .exceptions import (
File "C:\Python36-32\lib\site-packages\urllib3\exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "C:\Python36-32\lib\site-packages\urllib3\packages\six.py", line 203, in
load_module
mod = mod._resolve()
File "C:\Python36-32\lib\site-packages\urllib3\packages\six.py", line 115, in
_resolve
return _import_module(self.mod)
File "C:\Python36-32\lib\site-packages\urllib3\packages\six.py", line 82, in _
import_module
__import__(name)
File "C:\Python36-32\Lib\site-packages\upwork\http.py", line 6, in <module>
from compatibility import HTTPError, httplib
File "C:\Python36-32\Lib\site-packages\upwork\compatibility.py", line 8, in <module>
from http import client as httplib
ImportError: cannot import name 'client'
我的 Python 版本是 3.6.4。我尝试从 2.7.15 运行代码,但它之前产生了不同的错误,所以我将坚持使用 3.6.4。
另外,我之前遇到过一个错误:ImportError: attempted relative import with no known parent package
,但是在文件 http.py 中我替换了:
from .compatibility import HTTPError, httplib
和:
from compatibility import HTTPError, httplib
并且在当前错误之前可以正常工作。
我以前从未使用过 Python,但我未能尝试找到一种在 VBA 中获取 API 访问的方法,而 Python 有一个现有的解决方案。