Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'int' object has no attribute '_root' #21

Open
emi-netlist opened this issue Jul 7, 2023 · 13 comments
Open

AttributeError: 'int' object has no attribute '_root' #21

emi-netlist opened this issue Jul 7, 2023 · 13 comments

Comments

@emi-netlist
Copy link

Python 3.x
Windowing System is x11
Traceback (most recent call last):
File "/home/alice-desktop-1.3.pyw", line 140, in
ResDivStatus = IntVar(0)
File "/usr/lib/python3.10/tkinter/init.py", line 564, in init
Variable.init(self, master, value, name)
File "/usr/lib/python3.10/tkinter/init.py", line 372, in init
self._root = master._root()
AttributeError: 'int' object has no attribute '_root'

I'm receiving the error above after running: python3 alice-desktop-1.3.pyw

OS: Ubuntu 22.04

@damercer
Copy link
Contributor

damercer commented Jul 7, 2023

Hi:
This error is generated by the tk interface (tkinter) in your particular version of Python3.x.
Since this is a Python issue there is nothing I can do inside ALICE short of not using the tk library. Which is obviously not going to happen.

You might try finding where to post such issues in the Python support community. It might be something new in Ubuntu 22. Tested on earlier 20.x versions work fine.

It is interesting that just before that line (140) in the code tk string variables are defined and it chooses to not error there but on the int variable. What version level of Python 3 are you using?

I don't have access to Linux computer right now. Could you try editing the file as below as a test for me?

ResDivStatus = IntVar()
ResDivStatus.set(0)
ResDivDisp = IntVar()
ResDivDisp.set(0)

If this doesn't help I can't think of what might have changed in Python
Your cooperation on getting to the bottom of this seeming change to python is greatly appreciated.

@damercer
Copy link
Contributor

damercer commented Jul 7, 2023

I did a little more checking and it seems that a lot of things have changed between python 3.9 to 3.10. Finding and correcting all the places that these changes broke in the ALICE code may take a long time.
The near term fix is to revert to an older version of Python like 3.8 or 3.9.

@emi-netlist
Copy link
Author

emi-netlist commented Jul 7, 2023

Hy, yes I am using Python 3.10.6

I did what you said, but I had to replace every single instance of IntVar(0), and DoubleVar(0) with IntVar(), and DoubleVar() and also I had to add import tkinter on line 56 and it opens, but it tells me that PySMU is not found and I have installed libsmu. Did I miss something?

I don't know how to downgrade Python safely in Ubuntu. I know that if I remove python in Ubuntu whole system breaks and Im scared to do it.

@damercer
Copy link
Contributor

damercer commented Jul 7, 2023

Thanks for testing these apparently not backward compatible changes that were done to 3.10. I've switched to using Anaconda and the Python 10 that comes with that.
After installing Anaconda (Windows 10) and from here:
https://wiki.analog.com/university/tools/conda
typing: conda install -c conda-forge libsmu
in the Anaconda prompt console pysmu was installed.
Where/when does it say that pysmu was not installed. I've not gotten past issues with tkinter icon images and tkinter font issues!

@emi-netlist
Copy link
Author

It says after Alice opens.

I read in this guide https://wiki.analog.com/_media/university/tools/m1k/alice/linux-install-steps-v1.3.pdf that I have to install the python bindings, but apparently I can't do that either, it gives another error, so yes.

@damercer
Copy link
Contributor

damercer commented Jul 7, 2023

I've managed to change all the Intvar() lines (still using Anaconda/Spider) and commented out the photoimage references for the moment and the program "runs" without reporting any errors but none of the ALICE screens are being displayed? The console messages indicate that it is reading from the board and the LED changes from red to green so pysmu is working.
If you are python stand alone then yes you need to build the python bindings manually. That is what the conda install package route does for you.
I think there are instructions on building the python bindings from source manually in the libsmu repository readme file.

@emi-netlist
Copy link
Author

Oh I see, but It tells me to default to user installation because normal site-packages is not writeable.

Can I try to install it with pip? If so which .whl one to choose?
https://test.pypi.org/simple/pysmu/

@damercer
Copy link
Contributor

damercer commented Jul 7, 2023

I have no idea about installing libsmu / pysmu since Travis switched to using the conda packages. Thus why I'm beating my head against the Anaconda wall right now.

@emi-netlist
Copy link
Author

emi-netlist commented Jul 7, 2023

I used this one with Python 3.10: 'python3 -m pip install pysmu-1.0.4-cp310-cp310-manylinux_2_24_x86_64.whl' and it works.

Thank you so much for help. Ill report if I find anything strange.

@damercer
Copy link
Contributor

damercer commented Jul 7, 2023

I don't know what was going on with Anaconda and the tkinter package and Photoimage but if I abandon Anaconda and just do a standard install of Python 3.10 down loaded from the official Python site and install numpy / matplotlib and install the windows 64 pysmu bindings .whl down loaded from:
https://test.pypi.org/project/pysmu/#files
Everything works perfectly after replacing all the IntVar(0) with IntVar().

It will take some time for a full time Analog Employee to put a fixed version of the source code up in this repository.

@balbirthomas
Copy link

I had the same issue. I can confirm that the above discussed solution does work on Debian/GNU Linux version 12 with Python 3.11.2. I replaced every occurrence of IntVar(0) with IntVar() and every occurrence of DoubleVar(0) with DoubleVar() which fixes the issue. Thank you. Also I build and used latest libsmu and pysmu version 1.0.4 from its git repository.

@damercer
Copy link
Contributor

damercer commented Jul 9, 2023

Thanks for confirming that the changes also work on Python 3.11.
Updated Source code for all the ALICE related programs will be pushed to the version 1.3 repository in the coming days.
A reminder was also posted to the libsmu supporters to generate Python 3.11 bindings wheels when they can.

@rnayabed
Copy link

bump. encountered the same issue in 2024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants