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: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren' #104

Open
marcbennedbaek opened this issue Aug 21, 2024 · 9 comments
Assignees

Comments

@marcbennedbaek
Copy link

Hi!
I am trying to run sierra-local, but I get an error when I try to run with the example given I get an error message:
sierra_error message

The installation completed with no errors and I am able to see options for running the program.

I am running this with Python 3.10.9 on Ubuntu 20.04.06 LTS. I looked at a closed issue with a similar error, but there are differences, so it seems the error I encount is different from the one that is closed.

Not sure if it is just me doing something wrong or have misunderstood some directions.

Thanks!
Best regards,
Marc

@ArtPoon
Copy link
Contributor

ArtPoon commented Aug 21, 2024

Looks like we left a deprecated function in there
https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren
Most of our testing was back in the pre-3.9 era. I'll have a look.

@ArtPoon
Copy link
Contributor

ArtPoon commented Aug 21, 2024

Looks like I patched this problem a couple of years ago:
0310f13

Can you update sierralocal to the current version?

@marcbennedbaek
Copy link
Author

Thank you for the response!

I tried to reinstall again, but got the older version again. When I cloned from my browser instead of a terminal and installed from that repository I got the most recent version.

And now it works!

@ArtPoon
Copy link
Contributor

ArtPoon commented Aug 27, 2024

Glad you were able to resolve the problem. Strange that pulling from the repository in your terminal did not retrieve the latest version.

@ArtPoon ArtPoon closed this as completed Aug 27, 2024
@CEJ-R
Copy link

CEJ-R commented Jan 14, 2025

Hi there @ArtPoon!
So I'm re-opening this again, as I'm seeing the same issue as the person above:

sierralocal indata/my_input.fa
searching path /my/dir/Code/sierra-local/env/envs/sierra_local_250114/lib/python3.10/site-packages/sierralocal/data/HIVDB*.xml
searching path /my/dir/Code/sierra-local/env/envs/sierra_local_250114/lib/python3.10/site-packages/sierralocal/data/apobec*.tsv
HIVdb version 8.8
Traceback (most recent call last):
  File "/my/dir/Code/sierra-local/env/envs/sierra_local_250114/bin/sierralocal", line 11, in <module>
    exit_code = main.main()
  File "/my/dir/Code/sierra-local/env/envs/sierra_local_250114/lib/python3.10/site-packages/sierralocal/main.py", line 178, in main
    count, time_elapsed = sierralocal(args.fasta, args.outfile, xml=args.xml, tsv=args.tsv,
  File "/my/dir/Code/sierra-local/env/envs/sierra_local_250114/lib/python3.10/site-packages/sierralocal/main.py", line 108, in sierralocal
    writer = JSONWriter(algorithm)
  File "/my/dir/Code/sierra-local/env/envs/sierra_local_250114/lib/python3.10/site-packages/sierralocal/jsonwriter.py", line 19, in __init__
    self.definitions = self.algorithm.parse_definitions(self.algorithm.root)
  File "/my/dir/Code/sierra-local/env/envs/sierra_local_250114/lib/python3.10/site-packages/sierralocal/hivdb.py", line 128, in parse_definitions
    element_list = list(map(lambda x: xml.tostring(x).strip().decode("utf-8"), root.getchildren()))
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'

This after installing the proper version (or so I think?) through pip:
pip install sierralocal==0.2.1

I see that the latest one on git is 0.4, but the most recent in pip is 0.2.1. Is the pip-version out of date, then?

Thanks in advance for any help!

@ArtPoon
Copy link
Contributor

ArtPoon commented Jan 14, 2025

Sounds like the pip version is way out of date, we are at 0.4. Can you do an install directly from the GitHub repo? In the meantime I will look into updating the pip version.

@ArtPoon ArtPoon reopened this Jan 14, 2025
@CEJ-R
Copy link

CEJ-R commented Jan 14, 2025

Thanks for your quick reply, and it would be great if the pip-version is updated!

Installing through the repo: would this have to be done in this way, where it installs to /usr/local/lib. For "reasons" (working in a shared cluster) I need this to be installed in a conda/mamba env, or something similar.

@ArtPoon
Copy link
Contributor

ArtPoon commented Jan 14, 2025

Why not run python3 setup.py install --user if you don't have sudo?
Alternatively, you could make a virtual env within your home directory and install there:

cd ~
python3 -m venv venv
source venv/bin/activate
which python  # should return /home/<username>/venv/bin/python3
cd <to git clone dir>
python setup.py install

@ArtPoon
Copy link
Contributor

ArtPoon commented Jan 23, 2025

@WilliamZekaiWang can you please look into integrating pip updating into GitHub workflow?

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