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

Missing import TreeStyle #354

Closed
sebastianwindeck opened this issue May 10, 2018 · 37 comments
Closed

Missing import TreeStyle #354

sebastianwindeck opened this issue May 10, 2018 · 37 comments

Comments

@sebastianwindeck
Copy link

Installed Packages

Requirement already satisfied: ete3 in /usr/local/lib/python3.6/dist-packages (3.0.0b35)
Requirement already satisfied: PyQt5 in /usr/local/lib/python3.6/dist-packages (5.10.1)
Requirement already satisfied: sip in /usr/local/lib/python3.6/dist-packages (4.19.8)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (1.11.0)

Code to resproduce

Example Tree from Documentation: Documentation

from ete3 import Tree, TreeStyle t = Tree() t.populate(50, random_branches=True) t.convert_to_ultrametric() t.show()

Error message

ImportError: cannot import name 'TreeStyle'

Is there some change I missed in the package? Did the class 'TreeStyle' deprecated or did something else happen?

@jhcepas
Copy link
Member

jhcepas commented May 11, 2018

this is the usual error you get when some graphic libraries are not correctly installed.
Could you try importing import PyQt5? could it be you are mixing python versions?

@mapio
Copy link

mapio commented Jun 26, 2018

Really "this is the usual error you get when some graphic libraries are not correctly installed" @jhcepas?

This is an horrible way to signal the problem!

If TreeStyle requires PyQt5 this should be clearly reported in the requirements (your setup.py performs the test after the installation and just reports a warning), or at least should be imported in a try/catch that rises a more descriptive exception.

It's really bad for a new user to try the examples in the docs and have a completely uninformative ImportError: cannot import name 'TreeStyle' as a response.

@jhcepas
Copy link
Member

jhcepas commented Jun 26, 2018

I know! it is ugly! we need to fix this...

@EricDeveaud
Copy link

hello,

same problem here installed PyQt5 and ete3 in my ~/.local directory

module load Python/3.6.0
pip3 install --user PyQt5 ete3

and can't import TreeStyle

python3
Python 3.6.0 (default, Feb 20 2017, 18:52:46) 
[GCC 4.9.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
>>> from ete3 import TreeStyle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TreeStyle'
>>> 

NB

ete3 (3.1.1)
PyQt5 (5.13.1)

@EricDeveaud
Copy link

looking at pyqt libraries I found that (in my case) some system libraries were missing see:

 (py36) mob-suite:/opt/miniconda/envs/py36/lib/python3.6/site-packages/PyQt5> ldd *.so | grep 'not found'| sort | uniq
        libEGL.so.1 => not found
        libGL.so.1 => not found
        libXcomposite.so.1 => not found
        libXcursor.so.1 => not found
        libXdamage.so.1 => not found
        libXfixes.so.3 => not found
        libXi.so.6 => not found
        libXrandr.so.2 => not found
        libXss.so.1 => not found
        libXtst.so.6 => not found
        libasound.so.2 => not found

after installing missing libgGL.so.1

problem solved.

bigmess: ~ > python3.6 -c "from ete3 import TreeStyle"
bigmess: ~ > echo $?
0

@jhcepas
Copy link
Member

jhcepas commented Mar 28, 2020

related #444

@jhcepas jhcepas closed this as completed Mar 28, 2020
@biocyberman
Copy link

Still got this error on Python 3.6, MacOS Catalina, Miniconda 4.6.12

@axegard
Copy link

axegard commented Apr 9, 2020

I too have this error. Anyone have a temporary workaround? Importing PyQt5 v 5.14.2 does not resolve the issue.

Python 3.7, macOS Catalina 10.15.3 in a pipenv.

@dengzq1234
Copy link
Contributor

dengzq1234 commented Apr 9, 2020

As my experience,

for conda user, I would suggest install it as
conda install pyqt

for pip user, I would suggess install with
pip install PyQt5

These work for me

@exchhattu
Copy link

Following step suggested by @dengzq1234, It worked.

Installed using pip
pip3 install PyQt5

Called TreeStyle as below

Python 3.7.5 (default, Nov  1 2019, 02:16:32)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ete3 import PhyloTree, TreeStyle
>>>

@himanshub84
Copy link

pip3 install PyQt5==5.11.3
it will work for sure

@hjfsg95
Copy link

hjfsg95 commented Jun 17, 2020

tried PyQt5==5.14.0, PyQt5==5.11.3, not working
import PyQt5 works
just cannot import TreeStyle from ete3

@neel404
Copy link

neel404 commented Jul 13, 2020

Any workaround for this issue?

@krassowski
Copy link

If you are getting this error after the following sequence:

  1. Discovering you need to install PyQt5
  2. Installing PyQt5

you also need to (3) restart your Python and then it should work

@mapio
Copy link

mapio commented Oct 12, 2020

What do you exactly mean with "restart your Python"?

@krassowski
Copy link

  • if you are running Python as scripts - nothing,
  • if you use interactive Python session from command line - close it and open again,
  • if you use IPython kernel (e.g. in Jupyter) - restart the kernel.

@mapio
Copy link

mapio commented Oct 13, 2020

Isn't this obvious given that you suggest to install a new package? I thought you meant something more exotic…

@Cecilia-Sensalari
Copy link

Cecilia-Sensalari commented Dec 15, 2020

Hi, I had a TreeStyle import error as well and here is the story how I solved it:
I realized that I installed PyQt5 in /usr/lib/python3/dist-packages mostly likely by looking on the internet and using sudo apt-get. However, my program was using ete3 installed in /home/myname/.local/lib/python3.8/site-packages and it was looking for PyQt5 there too without success.
When I tried to install PyQt5 in that local folder with pip3, its installation was skipped because it found that it was already installed in the /usr/lib....
I solved by removing PyQt5 from /usr/lib... with sudo apt-get remove python3-pyqt5 and then by installing it again with pip3.
Hope this can help somebody else!

@jsgounot
Copy link

I've got the same problem. I installed ete3 (3.1.2) with conda, which installed pyqt (5.9.2) too. Now I've got the same error message but with nothing to help me.

@dengzq1234
Copy link
Contributor

dengzq1234 commented Mar 31, 2021 via email

@jsgounot
Copy link

I don't know, am I missing something ?

image

@dengzq1234
Copy link
Contributor

dengzq1234 commented Mar 31, 2021 via email

@jsgounot
Copy link

jsgounot commented Mar 31, 2021

['/home/jsgounot/anaconda3/envs/ete/bin', '/home/jsgounot/anaconda3/envs/ete/lib_pypy/__extensions__', '/home/jsgounot/anaconda3/envs/ete/lib_pypy', '/home/jsgounot/anaconda3/envs/ete/lib-python/3', '/home/jsgounot/anaconda3/envs/ete/lib-python/3/lib-tk', '/home/jsgounot/anaconda3/envs/ete/lib-python/3/plat-linux2', '', '/home/jsgounot/anaconda3/envs/ete/site-packages', '/home/jsgounot/anaconda3/envs/ete/site-packages/ete3-3.1.2-py3.7.egg', '/home/jsgounot/anaconda3/envs/ete/site-packages/IPython/extensions', '/home/jsgounot/.ipython']

Edit : Is there a place into ete3 code I can modify to have a better error message ?

@dengzq1234
Copy link
Contributor

dengzq1234 commented Mar 31, 2021 via email

@jsgounot
Copy link

/home/jsgounot/anaconda3/envs/ete/site-packages/PyQt5/__init__.py

@jsgounot
Copy link

jsgounot commented Apr 7, 2021

I finally searched a bit and this is an issue I have with PyQt5. Nevertheless, if you encounter the same issue, try this import, should be more meaningful : from ete3.treeview.main import TreeStyle

@dailing57
Copy link

I finally searched a bit and this is an issue I have with PyQt5. Nevertheless, if you encounter the same issue, try this import, should be more meaningful : from ete3.treeview.main import TreeStyle

It says I need QtPy4. But I've installed QtPy5. Should I install QtPy4 anyway?

@jhcepas
Copy link
Member

jhcepas commented Jun 10, 2021 via email

@dailing57
Copy link

no, it should work with Qt5. could you try if pyqt modules are importable regardless of ete3?

On Thu, 10 Jun 2021 at 13:49, dailing57 @.***> wrote: I finally searched a bit and this is an issue I have with PyQt5. Nevertheless, if you encounter the same issue, try this import, should be more meaningful : from ete3.treeview.main import TreeStyle It says I need QtPy4. But I've installed QtPy5. Should I install QtPy4 anyway? — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#354 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABH6SS2DUE6VY3FS6OIXHDTSCRDHANCNFSM4E7JIKXA .

Yes, I can import PyQt5 successfully. But I can't overcome the TreeStyle problem.

@stubbsrl
Copy link

I have worked my way through this thread trying the solutions and I am now at this same issue. I can also successfully import PyQt5 but when typing from ete3.treeview.main import TreeStyle
I get:
from PyQt4.QtGui import *
ModuleNotFoundError: No module named 'PyQt4'

@xguse
Copy link

xguse commented Sep 1, 2021

this is very frustrating. I know that that is not helpful. But I feel the need to express this.

@theo-allnutt-bioinformatics

This is still not working.

I have invested a lot of time writing ete3 code and the module is now broken on every machine I install it.

As stubbsrl said, I have also tried every solution and got to the ModuleNotFoundError: No module named 'PyQt4' one.

Is there any dev trying to solve this?

As above, I am using a fresh conda environment python 3.8.

@theo-allnutt-bioinformatics

Ok, because I am using CentOS, I had to do:

sudo yum install mesa-libGL

Then change import back to:

import PyQt5
from ete3 import Tree, PhyloTree,TreeStyle, NodeStyle, faces, AttrFace, CircleFace, TextFace

Now this seems to be working.

@knightjdr
Copy link

knightjdr commented Dec 3, 2022

To get this from ete3 import TreeStyle to work on Ubuntu 20.04, I had to install one package:

sudo apt-get update
sudo apt-get install -y libgl1

My minimal requirements file looks like:

ete3==3.1.2
numpy==1.23.5
PyQt5==5.15.7
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
six==1.16.0

@jeff-godwin
Copy link

Installed everything through conda and it worked for me.

python==3.6.13
PyQt5==5.15.7
PyQt5-sip==12.11.0 (installs along with pyqt)
ete3==3-3.1.2
numpy==1.23.4

Imported TreeStyle through ete3-
import PyQt5
import ete3
from ete3 import Tree, PhyloTree,TreeStyle, NodeStyle, faces, AttrFace, CircleFace, TextFace

Took me a day but got it working for cafe_fig. Cheers for all the pointers above!

@jungleblack007
Copy link

pip install PyQt5
works in my ubuntu in WSL

@kuang-da
Copy link

looking at pyqt libraries I found that (in my case) some system libraries were missing see:

 (py36) mob-suite:/opt/miniconda/envs/py36/lib/python3.6/site-packages/PyQt5> ldd *.so | grep 'not found'| sort | uniq
        libEGL.so.1 => not found
        libGL.so.1 => not found
        libXcomposite.so.1 => not found
        libXcursor.so.1 => not found
        libXdamage.so.1 => not found
        libXfixes.so.3 => not found
        libXi.so.6 => not found
        libXrandr.so.2 => not found
        libXss.so.1 => not found
        libXtst.so.6 => not found
        libasound.so.2 => not found

after installing missing libgGL.so.1

problem solved.

bigmess: ~ > python3.6 -c "from ete3 import TreeStyle"
bigmess: ~ > echo $?
0

I had the exact same error, and this is really helpful. Thank you!

For the missing libgGL.so.1, I did sudo apt install libgl1 as suggested here: https://stackoverflow.com/a/68666500/9936569

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

No branches or pull requests