# Python API connection

**URL:** <https://forum.asana.com/t/python-api-connection/159175>\
**Category:** API & Developers\
**Created:** [29 March 2022 04:07 UTC](https://forum.asana.com/t/python-api-connection/159175 "2022-03-29T04:07:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon42973371](https://luna1.co/8d76cd.png) [@anon42973371](https://forum.asana.com/u/anon42973371)\
**Post date:** [29 March 2022 04:07 UTC](https://forum.asana.com/t/python-api-connection/159175/1 "2022-03-29T04:07:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Will\_Morgan](https://luna1.co/8d76cd.png) [@Will\_Morgan](https://forum.asana.com/u/Will_Morgan)\
**Post date:** [27 September 2022 01:35 UTC](https://forum.asana.com/t/python-api-connection/159175/2 "2022-09-27T01:35:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Andy\_Pilipovic](https://luna1.co/8d76cd.png) [@Andy\_Pilipovic](https://forum.asana.com/u/Andy_Pilipovic)\
**Post date:** [31 October 2023 00:30 UTC](https://forum.asana.com/t/python-api-connection/159175/3 "2023-10-31T00:30:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![John\_Vu](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/john_vu/32/97235_2.png) [@John\_Vu](https://forum.asana.com/u/John_Vu)\
**Post date:** [31 October 2023 17:22 UTC](https://forum.asana.com/t/python-api-connection/159175/4 "2023-10-31T17:22:24Z")

</div>

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:

```plaintext
pip list

```

It should look like this:  
 ![pip_asana](https://us1.discourse-cdn.com/asana/original/3X/0/d/0d2cd07cb282bc81f149d4c3d3adfacad78faf86.png)

Make sure the “Version” is `3.2.2`

Also, are you using a [python virtual environment](https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/) 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):

```plaintext
import asana
from pprint import pprint

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

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

```

---

<div class="post-metadata">

**Author:** ![Andy\_Pilipovic](https://luna1.co/8d76cd.png) [@Andy\_Pilipovic](https://forum.asana.com/u/Andy_Pilipovic)\
**Post date:** [31 October 2023 17:24 UTC](https://forum.asana.com/t/python-api-connection/159175/5 "2023-10-31T17:24:32Z")

</div>

Hello @John_Vu,

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

Thanks once again!

---

<div class="post-metadata">

**Author:** ![Andy\_Pilipovic](https://luna1.co/8d76cd.png) [@Andy\_Pilipovic](https://forum.asana.com/u/Andy_Pilipovic)\
**Post date:** [2 November 2023 04:48 UTC](https://forum.asana.com/t/python-api-connection/159175/6 "2023-11-02T04:48:21Z")

</div>

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](https://us1.discourse-cdn.com/asana/original/3X/6/2/62310caabb58189ff36fe85c1a6fbad164a0bb1e.png)

---

<div class="post-metadata">

**Author:** ![Andy\_Pilipovic](https://luna1.co/8d76cd.png) [@Andy\_Pilipovic](https://forum.asana.com/u/Andy_Pilipovic)\
**Post date:** [2 November 2023 05:29 UTC](https://forum.asana.com/t/python-api-connection/159175/7 "2023-11-02T05:29:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Vu](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/john_vu/32/97235_2.png) [@John\_Vu](https://forum.asana.com/u/John_Vu)\
**Post date:** [2 November 2023 05:37 UTC](https://forum.asana.com/t/python-api-connection/159175/8 "2023-11-02T05:37:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [9 November 2023 05:37 UTC](https://forum.asana.com/t/python-api-connection/159175/9 "2023-11-09T05:37:54Z")

</div>

Closed on 9 November 2023 05:37 UTC

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