Python API connection

Hi All,

I am just send this error through a general question about making a connection to an Asana environment from Python in VSCode?

I have Python 3.8.8 as my base environment and I have successfully completed the asana package install.

However I get the following errors:

AttributeError : partially initialized module ‘asana’ has no attribute ‘Client’ (most likely due to a circular import)

this is the documented code I am running:

import asana

client = asana.Client.access_token(‘1/120136400xxxxxxxxxx’)

It seems to be complaining about the ‘Client’ is not a valid attribute of the asana package, so has anyone experience this issue before?? Are there any other environment to run the asana python code in?

Regards,

Adiran

This usually happens when the file you’re using is also called asana, hence trying to import itself.

3 Likes

I have this issue now popping up:

AttributeError: module ‘asana’ has no attribute ‘Client’

This code works on my desktop in VSCode however doesn’t work on my laptop.
Running package 3.2.2
Running Python 3.11.5

I tried with Asana 3.2.1 as well.
What could be at fault here?

Hi @Andy_Pilipovic ,

This error typically shows up if you have a different version of the library installed that doesn’t have a “Client” implemented. In the directory where you are testing your code can you type in your console:

pip list

It should look like this:
pip_asana

Make sure the “Version” is 3.2.2

Also, are you using a python virtual environment to install your packages? If not, it might be good to do so to avoid conflict with another asana python packages installed globally on your computer.

After you have confirmed that the package version you are using is indeed 3.2.2 try the following code sample (Replace <YOUR_PERSONAL_ACCESS_TOKEN> with your own Asana Personal Access Token):

import asana
from pprint import pprint

client = asana.Client.access_token("<YOUR_PERSONAL_ACCESS_TOKEN>")

result = client.users.get_user("me")
pprint(result)
1 Like

Hello @John_Vu,

I appreciate your response.
I played around and managed to get rid of the issue.

Thanks once again!

Me again, apparently this is still not working properly.
pip list shows Asana is 3.2.2.

I’ve tried with venv as well however I get the same response.

image

The issue was that for whatever reason my IDE was using the Microsoft Store python interpreter instead of the one I installed manually ;-;

Got it. Thank you for following up with your findings. Glad you got it working again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.