0

Can Someone Please help me? I have tried almost all the suggestions online and can't seem to find a working solution.

I have two PCs. Awhile ago I installed Anaconda3 and was able to get PyQt4 working with little to no effort. Unfortunately I can't remember what it was that I did.

I now need to have the code I wrote on the first PC to run on the second. But for some reason I cannot rollback the Qt or PyQt versions from 5 to 4. It seems the Qt packages are pretty complicated and also no longer have simple binary installers for python 3.6. The first PCs details are seen below: 1st PC with working Qt4 the second PC details are as follows:2nd PC details. So if I understand I somehow need to change the Qt version to 4.8.7 and PyQt to 4.11.4? I do not need Qt5 at all so don't mind if it is removed or uninstalled.

The relevant code that indicates that it works would just be the import of PyQt4 which as it stands leaves an error message of: "ModuleNotFoundError: No module named 'PyQt4'"

I have tried the suggestions here: How to install PyQt4 in anaconda? but get "unsatisfiableerror: the following specifications were found to be in conflict: -pyqt 4*-> python 2.6* -python 3.6*"

I have also tried installing SIP but had issues there as I could not build it using the anaconda terminal prompt. Conda install sip works but installs an older version that cannot support PyQt4.11.4.

I do not mind completely uninstalling anaconda and everything python in order to fix this.

Not sure if it makes a difference but the first PC is windows 10 and the second PC is windows 8. Any help would be greatly appreciated as I have almost lost my cool.

Nick Law
  • 115
  • 3
  • 13

4 Answers4

1

I'm guessing that you have a python 3.6 environment. There is no pyqt 4 package built for py36 in the official anaconda channels, but there is one in conda-forge. So you should be able to install the desired version by adding the extra channel

conda install -c conda-forge pyqt=4
ilmarinen
  • 4,557
  • 3
  • 16
  • 12
  • Hi, I have also tried that and got "UnsatisfiableError:The following specifications were found to be in conflict: -anaconda-navigator -pyqt 4* -python 3.6*" – Nick Law Sep 18 '17 at 20:00
  • I really cannot remember how I got the version that works on PC1. In the Ipython console it even displays:"Python 3.6.2 |Anaconda custom (64-bit)| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information." – Nick Law Sep 18 '17 at 20:02
  • You can get some clues by checking and comparing the versions of all packages you have installed using "conda list" or "conda list --export". I'ts possible youv'e done something like added the --force flag to the installation. It would bypass requirements on version. – ilmarinen Sep 18 '17 at 20:21
  • conda list didn't tell me much although I don't know what to look for. But this --force flag intrigues me. Is there a way to force install Qt4? The most ideal if I could just re-install everything and have it the same as PC1. – Nick Law Sep 18 '17 at 20:33
  • If you have the option of starting over, you can export the package list and then use that list to create the new environment [code] conda list --export > env_spec.txt [/code] Then use that file to create your environment on your other pc [code] conda create -n myenv --file env_spec.txt [/code] – ilmarinen Sep 20 '17 at 20:37
  • That looks like a great option! I am not too sure how environments work? I had tried creating an environment before but didn't see any changes within Spyder etc even though I activated it. Would it be possible to get the list [code]conda list --export > env_spec.txt[/code] and then somehow install this list? I.e not use an environment but have exactly the same setup? – Nick Law Sep 21 '17 at 21:23
  • If both environments are root environments (i.e. the one you installed with the installer, not with "conda create"), it whould work by doing a "conda install..." instead of "conda create...". – ilmarinen Sep 21 '17 at 21:42
  • So I tried it out and had two issues. First the packages that were pip installed were not added to the exported list. I tried adding them to the list as they were seen in the cmd prompt (PyQt4=4.11.4=) and (pyserial=3.4=) but got "PackageNotFoundError:Package missing in current channels". I then removed those to pip install later. I then got "UnsatisfiableError: the following specifications were found to be in conflict: -argcomplete -pytest 3.0.5 py36_0". google returned nothing useful. I'll try create an environment in the mean time – Nick Law Sep 21 '17 at 23:12
0

Christoph Gohlke has qt4 wheels built: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4

erkyky
  • 107
  • 6
  • Hey Yeah I tried that before and got an Exception: PermissionError:[Errno 13] permission denied. Any idea why? – Nick Law Sep 18 '17 at 19:55
  • I am not sure what I changed but I retried the above and now I get"Requirements already satisfied: PyQt=4.11.4 in ..\site-packages". However I still get "ModuleNotFoundError: No module named 'PyQt4'" when I tried running the code. I somehow need to force Spyder(Or anaconda?) to use PyQt4. Unsure how – Nick Law Sep 18 '17 at 21:34
0

Try installing with pip, this might work

python -m pip install --upgrade pyqt4
S_Ymln
  • 421
  • 3
  • 14
  • I had not tried that before. I got the following message:"Requirement already up-to-date: pyqt4 in c:\users\nick\anaconda3\lib\site-packages". Not to sure what that means or if it helps? – Nick Law Sep 18 '17 at 20:19
  • It means you have pyqt4 and try to check if you have the above mentioned Path environment variables. you can check with os.path – S_Ymln Sep 18 '17 at 20:25
  • Sorry? above mentioned Path environment variables? can you suggest what i do? – Nick Law Sep 18 '17 at 20:27
  • I assume PyQt4 is installed but how to I ensure it is implemented now? – Nick Law Sep 18 '17 at 21:35
  • Assuming you are running a windows machine, Go to system properties-> advanced system settings-> environment variables add new path with the path shown above that should work. – S_Ymln Sep 18 '17 at 22:00
0

Hi Guys so I found a solution that works for me. This will only really work if you do not need PyQt5. I basically completely removed all python and anaconda packages and reinstalled an older version that had the exact packages I needed. This is not ideal if you have a whole lot of other packages or plugins already installed(pyserial for example).

I basically used: "conda info anaconda" and searched through all the versions that had both python 3(and above) as well as Qt4 and PyQt4. In my case anaconda 4.1.1 did the trick(specifically anaconda3 with python 3.5). Then you can either download the .tar that is given from the info(https://repo.continuum.io/pkgs/free/win-64/anaconda-4.1.1-np111py34_0.tar.bz2) OR you can download the installer from (https://repo.continuum.io/archive/).

The code now works(a little buggy but I expect that is because I now use python 3.5 instead of python 3.6). So I will try upgrade the python version and see if that helps.

In short, it seemed to be far easier to do it this way than trying to roll back the Qt versions or any of the other methods I tried above.

I hope this helps someone in the Future.

Nick Law
  • 115
  • 3
  • 13