Python 3 can't find homebrew pyqt installation - python

I recently used homebrew to install pyqt (along with qt & sip), but get an import error whenever I try to import PyQt4 in Python 3 (which was also installed using homebrew). To confuse matters more, I am able to import PyQt4 on Python 2 via the terminal.
I'm totally new to working with Python packages and, with that, totally confused. Any thoughts on how I might be able to undo what I did and reinstall so that I can access PyQt via the usr/local/python3 installation?
Thanks in advance!

brew reinstall pyqt --with-python3 will get you sorted!

There will be seperatelibrary files for python2 and python3. From your question, it seems that you have installed pyqt for python2 which you can't import in python3.
For python3, you have to install specific package developed for python3.
Here is a similar question regarding python3 pyqt installation using homebrew. It says, there is currently some limitation with homebrew.
Install pyqt via homebrew with `--with-python3` but still goes to Python 2
EDIT:
Developer of homebrew has resolved the issue.

Related

When I try to install PySimpleGUI (4.53.0) in jupyter notebook using Python 3.8 the error "no module named 'PySimpleGUI' is returned

I have already used pip install pysimplegui, using pip list shows that it is installed in Terminal (I use a mac). I also made sure it was the most recent version of pysimplegui.
I'm newer to coding some I'm not sure what other information to put here. Any advice would be enormously helpful. I am using Jupyter Notebook through Anaconda.
I should add that before this I tried doing the same thing with easygui and had the exact same error.
In the anaconda terminal use python -m pip install PySimpleGUI so you install it in the python being used.
Mixing pip install and conda install is not to recommend, although sometimes unavoidable. What has happened in your case is not related to this conflict, though. In this case, the wrong pip was invoked when installing the package, so it was installed for a different python interpreter than the one you're using to run the notebook. You can have several python versions installed globally, both python(2) and python3. Furthermore, you may have even more versions of python in virtual environments, so you need to pay attention to which version you want to install a package for.
In case you don't have any specific reason not to, you'll save yourself some future headaches by using the conda package management system over pip to avoid those situations where they don't play nice with each other and you end up with a broken or unpredictable package setup.
Note that I'm not saying conda is better than pip in any way, I'm only proposing going with conda since you're using the Anaconda environment and its preinstalled packages already.
copy from PySimpleGUI
https://pysimplegui.readthedocs.io/en/latest/
Warning - tkinter + Python 3.7.3 and later, including 3.8 has problems
The version of tkinter that is being supplied with the 3.7.3 and later versions of Python is known to have a problem with table colors. Basically, they don't work. As a result, if you want to use the plain PySimpleGUI running on tkinter, you should be using 3.7.2 or less. 3.6 is the version PySimpleGUI has chosen as the recommended version for most users.

Python: installing packages on Mac

I tried to install the pyqt5 package für python 3.9 on Mac.
Since it didn't work via pip3 I installed it via Homebrew
% brew install pyqt5
and it seemed to work since the terminal says, if I try
pip3 install pyqt5
the requirements are already satisfied.
Yet, if I start PyCharm to to write and test my program it can't find the libraries etc.
What do I have to do?
I just tried to brew install pyqt5 on my Mac. brew then installed a new Python 3.9 interpreter (this is viewed as a dependency of pyqt5).
I suspect the same has happened on your system: brew has installed a whole new Python interpreter, and now when you type pip3 at the command line, you're finding the version of pip installed by brew, which is telling you that pyqt5 has been installed.
However, each Python installation on your system as its own set of packages. Your new Python interpreter has pyqt5 installed, but your original Python interpreter still doesn't.
I suspect that PyCharm is configured to use your default (original) Python interpreter, which doesn't have pyqt5 installed.
Try executing the following at your command prompt (terminal): which pip3. If you're shown a path /usr/local/Cellar/... then this confirms that when you type pip3 at the command line you're actually referring to the version of pip corresponding to a Python interpreter installed by brew.
OK, so what to do going forward?
Two options:
Work with this new Python installation. Then, you'll need to install all of the packages in your previous version of Python again (e.g. just because you had Numpy installed on your original Python installation doesn't mean you'll have it installed by default for your new Python interpreter). Further, you'll have to configure Pycharm to use this Python installation. I don't know the exact steps for this, but go to the Preferences tab and look for something along the lines of 'Python Interpreter' underneath 'Project Settings'.
Remove the new Python installation, figure out what's up with pip, install your desired package.
I'd go with 2). It can get messy to have multiple different versions of Python on your system, unless they're managed by an environment manager such as conda.
To that end, what went wrong when you first tried to install pyqt5?

How to install pygame, cv2, anaconda, pip etc to any one version of python in ubuntu 14.04

I have Ubuntu 14.04 LTS. I guess different versions of python are pre-installed in Ubuntu 14.04. Right now when I type 'python' in terminal it opens python 2.7.11, but I guess the default version of Ubuntu 14.04 is 2.7.6. When I type /usr/bin/python it opens the default version. I know this can be done with making aliases. The real problem is, I have installed pygame, cv2 (that is for image processing) using apt-get. These are installed for default version of python i.e python 2.7.6. Also I have installed anaconda with python 2.7.11 using pip, but again 'pip' and anaconda are installed for 2.7.11. I know python 3 is also pre-installed there but I don't use it. Also I have no python version installed in user/local/bin.Now I want to know why this problem is occurring? How can I fix this now? Also how to import all the libraries for one python version(either default or another) and how to use it? How to configure my settings so that I would not have any problem in future?
If you have easy_install installed you can run
sudo easy_install pip
to install pip. As far as installing Anaconda goes, try using this stack overflow question's answer. If you can't get that to work comment explaining the issue.
First of all I want to thanks Bennet for responding to my question so that I was able to figure out what the problem was. Actually the problem was with aliasing. When I installed cv2 or pygame using apt-get, they were installed for default version but when I installed any package by downloading the installer first (like I installed anaconda), it was installed for python 2.7.11 because 'python' was aliased for this version(that is 2.7.11). So, basically make sure that the default version for which you want to install everything is the one which is aliased as 'python', and everything goes fine. I aliased 'python' for the default version and then installed anaconda via installer and now it has been installed default version.

Installing PySide without PIP

I'm trying to install PySide on my work computer. I got everything installed at home which was simple enough. However at work I'm stuck behind a firewall which I can't get around and therefore can't install PIP.
Is there a binary for PySide that I might be able to use or any other solution?
Thanks!
OS is Win 7 32-bit
Also I'm using Python 3.4
You will find it here (it is an executable):
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyside
Enjoy! :)
You can download the wheel distribution from PyPI [1] and install with PIP offline.
And you don't loose the benefits of installing packages via PIP.
https://pypi.python.org/pypi/PySide#downloads
Here is direct link to package for your system and python version: https://pypi.python.org/packages/3.4/P/PySide/PySide-1.2.2-cp34-none-win32.whl

How to install PyQt4 on Windows using pip?

I'm using Python 3.4 on Windows. When I run a script, it complains
ImportError: No Module named 'PyQt4'
So I tried to install it, but pip install PyQt4 gives
Could not find any downloads that satisfy the requirement PyQt4
although it does show up when I run pip search PyQt4. I tried to pip install python-qt, which installed successfully but that didn't solve the problem.
What am I doing wrong?
Here are Windows wheel packages built by Chris Golke - Python Windows Binary packages - PyQt
In the filenames cp27 means C-python version 2.7, cp35 means python 3.5, etc.
Since Qt is a more complicated system with a compiled C++ codebase underlying the python interface it provides you, it can be more complex to build than just a pure python code package, which means it can be hard to install it from source.
Make sure you grab the correct Windows wheel file (python version, 32/64 bit), and then use pip to install it - e.g:
C:\path\where\wheel\is\> pip install PyQt4-4.11.4-cp35-none-win_amd64.whl
Should properly install if you are running an x64 build of Python 3.5.
QT no longer supports PyQt4, but you can install PyQt5 with pip:
pip install PyQt5
You can't use pip. You have to download from the Riverbank website and run the installer for your version of python. If there is no install for your version, you will have to install Python for one of the available installers, or build from source (which is rather involved). Other answers and comments have the links.
If you install PyQt4 on Windows, files wind up here by default:
C:\Python27\Lib\site-packages\PyQt4*.*
but it also leaves a file here:
C:\Python27\Lib\site-packages\sip.pyd
If you copy the both the sip.pyd and PyQt4 folder into your virtualenv things will work fine.
For example:
mkdir c:\code
cd c:\code
virtualenv BACKUP
cd c:\code\BACKUP\scripts
activate
Then with windows explorer copy from C:\Python27\Lib\site-packages the file (sip.pyd) and folder (PyQt4) mentioned above to C:\code\BACKUP\Lib\site-packages\
Then back at CLI:
cd ..
(c:\code\BACKUP)
python backup.py
The problem with trying to launch a script which calls PyQt4 from within virtualenv is that the virtualenv does not have PyQt4 installed and it doesn't know how to reference the default installation described above. But follow these steps to copy PyQt4 into your virtualenv and things should work great.
Earlier PyQt .exe installers were available directly from the website download page. Now with the release of PyQt4.12 , installers have been deprecated. You can make the libraries work somehow by compiling them but that would mean going to great lengths of trouble.
Otherwise you can use the previous distributions to solve your purpose. The .exe windows installers can be downloaded from :
https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/
It looks like you may have to do a bit of manual installation for PyQt4.
http://pyqt.sourceforge.net/Docs/PyQt4/installation.html
This might help a bit more, it's a bit more in a tutorial/set-by-step format:
http://movingthelamppost.com/blog/html/2013/07/12/installing_pyqt____because_it_s_too_good_for_pip_or_easy_install_.html
With current latest python 3.6.5
pip3 install PyQt5
works fine
For Windows:
download the appropriate version of the PyQt4 from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
and install it using pip (example for Python3.6 - 64bit)
pip install PyQt4‑4.11.4‑cp36‑cp36m‑win_amd64.whl
Try this for PyQt5:
pip install PyQt5
Use the operating system on this link for PyQt4.
Or download the supported wheel for your platform on this link.
Else use this link for the windows executable installer.
Hopefully this helps you to install either PyQt4 or PyQt5.
install PyQt5 for Windows 10 and python 3.5+.
pip install PyQt5
If you have error while installing PyQt4.
Error: PyQt4-4.11.4-cp27-cp27m-win_amd64.whl is not a supported wheel on this
platform.
My system type is 64 bit, But to solve this error I have installed PyQt4 of 32 bit windows system, i.e PyQt4-4.11.4-cp27-cp27m-win32.whl - click here to see more versions.
Kindly select appropriate version of PyQt4 according to your installed python version.
You can also use this command to install PyQt5.
pip3 install PyQt5
I am using PyCharm, and was able to install PyQt5.
PyQt4, as well as PyQt4Enhanced and windows_whl both failed to install, I'm guessing that's because Qt4 is no longer supported.
Try using python 3.6,
then install sip
pip install sip
then follow the steps mentioned by #Jay https://stackoverflow.com/a/48078369/8352081

Categories