Upwork API Python Library - ImportError: Cannot Import Name 'client'

- 1 answer

I have a problem when using Python Upwork library. It has been installed through PIP.

In ...\site-packages\upwork\ I created file.

The content of this file is so far:


import upwork

Here's traceback from cmd line:

Traceback (most recent call last):
  File "", line 4, in <module>
    import upwork
  File "C:\Python36-32\lib\site-packages\upwork\", line 23, in <module>
    from upwork.client import Client
  File "C:\Python36-32\lib\site-packages\upwork\", line 8, in <module>
    import urllib3
  File "C:\Python36-32\lib\site-packages\urllib3\", line 8, in <module>
    from .connectionpool import (
  File "C:\Python36-32\lib\site-packages\urllib3\", line 11, in <module>
    from .exceptions import (
  File "C:\Python36-32\lib\site-packages\urllib3\", line 2, in <module>
    from .packages.six.moves.http_client import (
  File "C:\Python36-32\lib\site-packages\urllib3\packages\", line 203, in
    mod = mod._resolve()
  File "C:\Python36-32\lib\site-packages\urllib3\packages\", line 115, in
    return _import_module(self.mod)
  File "C:\Python36-32\lib\site-packages\urllib3\packages\", line 82, in _
  File "C:\Python36-32\Lib\site-packages\upwork\", line 6, in <module>
    from compatibility import HTTPError, httplib
  File "C:\Python36-32\Lib\site-packages\upwork\", line 8, in <module>
    from http import client as httplib
ImportError: cannot import name 'client'

My Python version is 3.6.4. I tried to run code from 2.7.15, but it generated a different error earlier, so I will stick to 3.6.4.

Also, I've been getting one error earlier: ImportError: attempted relative import with no known parent package, but in file I replaced:

from .compatibility import HTTPError, httplib


from compatibility import HTTPError, httplib

and it works okay until current error.

I have never used Python before, but I failed trying to find a way to get API access in VBA and Python has an existing solution.



As mentioned in comments, place the script not inside the upwork package folder (e.g. just try user homedir).

The reason is, the site-packages/upwork folder defines the upwork package contents, so import upwork will not work from this location. In this way you are actually adding a upwork.myauth package.