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

PyQt5 and Anaconda trouble #138

Closed
David-OConnor opened this issue Jun 26, 2014 · 30 comments
Closed

PyQt5 and Anaconda trouble #138

David-OConnor opened this issue Jun 26, 2014 · 30 comments

Comments

@David-OConnor
Copy link

Qt doesn't like having multiple versions installed at the same time: 'RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class', after installing PyQt5 with Anaconda.

I got Qt5 working using 'conda remove PyQt', followed by 'f'[orce] . This must be done before installing PyQt5, since it removes sip. Also had to 'conda remove matplotlib' with a force, and reinstall it from the LFCI packages website. Ipython GUI and Spyder too. (Haven't found a workaround like this for Linux yet)

Is there a way to have PyQt 4 and 5 installed at the same time Anaconda? I'd like to be able to use PyQt5 without breaking Spyder, Matplotlib and IPython.

@asmeurer
Copy link
Contributor

Unless you need them from the same scripts, I would just create a separate conda environment for pyqt5, like conda create -n pyqt5 python.

@David-OConnor
Copy link
Author

Ideally, two environments would not be required. One of the appeals of Anaconda (and the main one for me) is its clean, batteries-included package system. These workarounds diminish the advantage to the point where it may be cleaner to just use Chris Gohlke's Windows installers, or Ubuntu packages.

@asmeurer
Copy link
Contributor

asmeurer commented Jul 3, 2014

Unless you can install both pyqt4 and pyqt5 in the same environment, you will have to have separate environments. Anaconda comes with things that require pyqt4, like the ipython qtconsole and spyder.

@David-OConnor
Copy link
Author

I installed PySide. It's coexisting with PyQt5. Anaconda's Ipython and Spyder now work properly. Anaconda's Matplotlib still doesn't: It seems to require PyQt4. Ipython and Spyder appear to work with PyQt4 or Pyside.

@asmeurer
Copy link
Contributor

asmeurer commented Jul 3, 2014

Sure, but we have already decided to use pyqt instead of pyside by default in Anaconda.

@David-OConnor
Copy link
Author

Got it working on Ubuntu cleanly. This indeed comes down to PyQt's caveat "Unfortunately it is not possible to use both the PyQt4 and PyQt5 installers at the same time. If you wish to have both PyQt4 and PyQt5 installed at the same time you will need to build them yourself from the source packages."

Solution: 'conda remove sip'. Install sip 4.16 from source. Install PyQt5 from source. Everything works.

@ddale
Copy link

ddale commented Aug 13, 2014

I've been working on Qt5/sip/PyQt5 conda packages that is installable alongside Qt4/PyQt4 (http://binstar.org/dsdale24), but there is are two issues with the existing pyqt conda package on windows.

  1. pyqt installs a qt.conf file into the root Anaconda directory, which breaks the Qt5 installation. It
    appears that the qt.conf file is not necessary for the pyqt package, as its contents are irrelevant to
    the installation location (C:\Anaconda on my system):

    [Paths]
    Prefix = C:/aroot/stage/Lib/site-packages/PyQt4
    Binaries = C:/aroot/stage/Lib/site-packages/PyQt4
    
  2. The pyqt package is providing an older sip.pyd than what I needed to use to create the pyqt5
    package. Sip is a separate package, pyqt should not be providing its dlls.

I can get pyqt and pyqt5 installed side-by-side on windows by installing in the following order (assumes pyqt, qt5, sip, pyqt5 are not already installed):

  1. conda install pyqt
  2. delete the qt.conf file from the Anaconda root directory (next to python.exe)
  3. conda install pyqt5

But if I then do conda install -f pyqt, it overwrites the sip.pyd file provided by the sip conda package and reinstalls the errant qt.conf, breaking pyqt5.

@ddale
Copy link

ddale commented Aug 17, 2014

By the way, the issues I mentioned should be easy to address. Just tweak the pyqt recipe to get rid of the qt.conf file, it is not needed, get rid of the sip.pyd file, and have pyqt depend on the sip package.

@stlehmann
Copy link

I also got trouble using PyQt5 in a conda environment. I did the following steps:

  • install PyQt5 package in conda root with conda install pyqt5
  • create a new environment with conda create -n myenv
  • install PyQt5 package in the new environment with conda install pyqt5

When I tried to import PyQt5.QtWidgets module I got the following error:

>>> from PyQt5.QtWidgets import *
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application

I got the whole thing working by copying the Qt directory (c:\miniconda3\Lib\site-packages\PyQt5\Qt) from the root environment to the virtual environment. Still I' m not happy with this solution. Does somebody know a better way?

@goanpeca
Copy link

@ccordoba12 ?

@ccordoba12
Copy link

@MrLeeH, we still don't have official packages for PyQt5, so I don't know where you get them.

@ccordoba12
Copy link

I don't know where those packages are coming from. Please contact the author and talk to him/her about the problems you're having :-)

@stlehmann
Copy link

Alright thanks, I' ll do this. Is there going to be an official PyQt5 support in the future?

@mingwandroid
Copy link

Yes, please use https://anaconda.org/qttesting channel to test.

@stlehmann
Copy link

@mingwandroid Thanks for this tipp. I tried the pyqt package from https://anaconda.org/qttesting and it works out of the box. Why is it still declared as testing?

@ccordoba12
Copy link

Because we haven't moved them to our main channels :-) Sorry for not mentioning those packages, but we're working on the last details before announcing them publicly.

@mingwandroid
Copy link

@ccordoba12, I figured that by mentioning them we'd get some extra testing, apologies if you'd rather I didn't.

@ccordoba12
Copy link

@mingwandroid, no problem if you take the bullets for problems about them ;-) I don't have time to give them support right now.

@stlehmann
Copy link

So this finally seems to work. Maybe this issue should be closed. Just installed PyQt5 from the default channel.

@phpmind
Copy link

phpmind commented Apr 5, 2017

pip install PyQt5 :::

After struggling 2 hrs, finally, this worked for me. Just wanted to share.

@Lyoyanu
Copy link

Lyoyanu commented Feb 1, 2018

conda install -c dsdale24 pyqt5

Try this one . It works for me .

@DaveDave9994
Copy link

Im having this issue on a virgin anaconda install.
OS = Win 10
anaconda = Anaconda3-5.3.0-Windows-x86_64
python = 3.7

Im playing around with PyQt5. When i run the following in Spyder it works.
import sys from PyQt5.QtWidgets import QApplication, QWidget

When i run it in Visual Studio i get the following error
"ModuleNotFoundError: No module named 'pyqt5'"

Is there a definitive fix for this?

@mingwandroid
Copy link

@DaveDave9994, did you activate your environment before launching Sypder?

You may have run into local packages causing problems. Perhaps try conda update python. More info at #10236

@DaveDave9994
Copy link

I have uninstalled and made sure that anaconda is the only package for python. C:\Users\antho\Anaconda3

if i pip install pyqt5 i break anaconda and need to unistall, clean then reinstall.
if i conda install pyqt5 i get PackagesNotFoundError:

Im thinking of getting rid on anaconda and doing a straight Python3.7 install.

@msarahan
Copy link
Contributor

msarahan commented Nov 1, 2018

@ccordoba12
Copy link

if i conda install pyqt5 i get PackagesNotFoundError

It's conda install pyqt, not conda install pyqt5

@Runekeon
Copy link

The fact that this issue has been causing problems since 2014 and I'm having it in 2019 makes me think Anaconda is not worth it.

@mingwandroid
Copy link

@Runekeon, I hope you find what you are looking for, good luck!

@aron-alarik
Copy link

tried all of the solutions above, still facing the same issue: the moment I install pyqtgraph (latest version) or update PyQT, anaconda stops working !!

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