# AttributeError: 'str' object has no attribute 'setText'

**URL:** <https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-settext/36080>\
**Category:** Builder\
**Tags:** psychopy3\
**Created:** [August 12, 2023, 6:44pm UTC](https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-settext/36080 "2023-08-12T18:44:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmtoma](https://avatars.discourse-cdn.com/v4/letter/f/58f4c7/32.png) [@fmtoma](https://discourse.psychopy.org/u/fmtoma)\
**Post date:** [August 12, 2023, 6:44pm UTC](https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-settext/36080/1 "2023-08-12T18:44:58Z")

</div>

If this template helps then use it. If not then just delete and start from scratch.

**OS** (e.g. Win10): **Windows10**  
**PsychoPy version** (e.g. 1.84.x): **v2021.1.3**  
**Standard Standalone? (y/n)** If not then what?:  
**What are you trying to achieve?:**

Hello,

I have an experiment that has the following routine:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/c/4c6816a68c416a8cc47c1a4889281a3a5476ee0f.png)

It is part of a loop that has the following file:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/8/489f20c6fe85be88dc8220b61b3fb913e8f75137.png)

All the cells from the Excel file are defined as text (tried defining them as General, but still received errors):

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/8/78ab030cdc987bf0ce1c5d6d7f034c790d7c3998.png)

**When I reach this routine, I receive this error message:**  
prac2\_letter.setText(twoback)  
AttributeError: ‘str’ object has no attribute ‘setText’

**What did you try to make it work?:**  
I tried renaming the Excel file, the text component, the column name, formatting the cells as Text and General.

Note: I have another file with the exact same routines that does not produce this error.

Do you have any idea on why this happens? I tried looking everywhere and couldn’t find anything.

---

<div class="post-metadata">

**Author:** ![Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/chen/32/38825_2.png) [@Chen](https://discourse.psychopy.org/u/Chen)\
**Post date:** [August 12, 2023, 8:57pm UTC](https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-settext/36080/2 "2023-08-12T20:57:57Z")

</div>

Hello,  
Is it possible that you have two spreadsheets with the same column name?  
See the following:

> [@AttributeError: 'str' object has no attribute 'setColor'](https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-setcolor/29293/2):
>
> Try renaming the Word object to something else, as there’s a warning on it having the same name as the string column $Word in your conditions.xlsx file. No errors when I changed the text object to wordle.

Chen

---

<div class="post-metadata">

**Author:** ![fmtoma](https://avatars.discourse-cdn.com/v4/letter/f/58f4c7/32.png) [@fmtoma](https://discourse.psychopy.org/u/fmtoma)\
**Post date:** [August 12, 2023, 9:12pm UTC](https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-settext/36080/3 "2023-08-12T21:12:08Z")

</div>

No, I don’t have 2 spreasheets with the same name.

I had seen that topic too → but I only have one spreadsheet in the entire experiment that is named “practice.xlsx”.

In addition, I tried renaming both the actual spreadsheet and the column name multiple times and I receive the same error message, regardless of what names I put.

---

<div class="post-metadata">

**Author:** ![Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/chen/32/38825_2.png) [@Chen](https://discourse.psychopy.org/u/Chen)\
**Post date:** [August 13, 2023, 12:12am UTC](https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-settext/36080/4 "2023-08-13T00:12:47Z")

</div>

I see.  
Any chance you could share the experiment?  
Also, why is your start time set to `condition` instead of `time (s)`?

Thanks,  
Chen

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [August 13, 2023, 3:53pm UTC](https://discourse.psychopy.org/t/attributeerror-str-object-has-no-attribute-settext/36080/5 "2023-08-13T15:53:41Z")

</div>

The error message suggests that you are using the name of the component (prac2\_letter) in a code component at some point, and setting it as a text variable.
