Upwork API Python Library - ImportError: Cannot Import Name 'client'
I have a problem when using Python Upwork library. It has been installed through PIP.
In ...\site-packages\upwork\ I created myAuth.py file.
The content of this file is so far:
apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
secretKey = 'XXXXXXXXXXXXXXXXXX'
import upwork
Here's traceback from cmd line:
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'
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 http.py I replaced:
from .compatibility import HTTPError, httplib
with:
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.
Answer
As mentioned in comments, place the myauth.py
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.
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module