can't install pyside and QT Mac OSX 10.9 - python

I'm more or less new to python
I'm trying to install pyside and QT on a mac but I can't figure out how to install them.
I downloaded install files "pyside-1.1.0-qt47-py27apple.pkg" from http://qt-project.org/wiki/PySide_Binaries_MacOSX and "Qt libraries 4.8.5 for Mac" from http://qt-project.org/downloads.
double click on both files and installed. but it looks like it didn't work.
I can import PySide but nothing else.
in Python Idle when I type
import PySide
print PySide.__version__
1.1.0
then if I do:
import PySide.QtCore
I get this error.
Traceback (most recent call last): File "", line 1, in
import PySide.QtCore ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Library
not loaded: QtCore.framework/Versions/4/QtCore Referenced from:
/Library/Python/2.7/site-packages/PySide/QtCore.so Reason: no
suitable image found. Did find:
/Library/Frameworks/QtCore.framework/Versions/4/QtCore: mach-o, but
wrong architecture
I have python 2.7 and PyCharm. I also have installed setuptools and pip.
I looked around online and I see a lot of people had the same problem. but I couldn't find any answer that worked for me.
I hope anyone can help me out with this.

This worked for me:
sudo pyside_postinstall.py -install
Note: I'm using PySide 1.2.2, Qt 4.8.6, Mac OS X 10.9.3.
Edit: There is no more need to call the post-install script on Linux and MacOS systems since version 1.2.3 (2015-10-12).

Related

pyuic5 - ModuleNotFoundError: No module named PyQt5.sip

I have just installed Anaconda 5.2 with Python 3.6 on my windows system. Also installed pyqt5 and pyqt5-tools via pip with administrator privilege. Now when I run pyuic5.exe for converting ui files it shows following error:
Traceback (most recent call last):
File "C:\Users\AshfaqurRahman\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\AshfaqurRahman\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\AshfaqurRahman\AppData\Roaming\Python\Python36\site-packages\PyQt5\uic\pyuic.py", line 26, in <module>
from PyQt5 import QtCore
ModuleNotFoundError: No module named 'PyQt5.sip'
I have tried installing PyQt5-sip package using pip. Buts its already installed in my system.
Why this problem is occurring? How can I solve this problem?
According to Agile_Eagle's suggestion from the comments I just uninstalled pyqt5 and pyqt5-tools packages and the reinstalled them. Problem solved!
PS.: If you still got problems with PyQt, try uninstalling all of the PyQt related libraries:
pip uninstall PyQt5
pip uninstall PyQt5-sip
pip uninstall PyQtWebEngine
Then install them again, this will fix:
ModuleNotFoundError: No module named 'PyQt5.sip'
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
PPS.:If you got problems uninstalling the libraries, go to your Python folder, like C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python<PYTHON-VERSION>\Lib\site-packages and manually delete the PyQt folders, then uninstall everything and install again (Make sure you have the latest Python version and upgraded your pip too)
As of June 2019, pyqt5-tools no longer exists.
The solution I found was first installing pyqt5-sip and then install pyqt5
$ pip install pyqt5-sip
$ pip install pyqt5
This seems to get rid of the following error: ModuleNotFoundError: No module named 'PyQt5.sip'
None of the answers above worked for PyQt5 5.13.0 on conda's python 3.6.
With pyqt5 and pyqt5-sip installed just go into python's site-packages and copy sip.so from the PyQt5_sip package to PyQt5 folder (or make a symlink) where the rest of Qt's so modules are.
Seems like a poor decision to pull sip out into a separate package.
I am a Mac user and I had faced a similar issue.
However, I understand for window users, what you are looking for is pyuic5.bat and not pyuic5.sip
It seems you'll simply have to provide the full path of the pyuic file(for me, it was under a hidden folder usr in the home directory: /usr/local/Cellar/pyqt/5.10.1_1/bin/pyuic5) and do make sure on your terminal(for you, cmd) you have the directory changed to where the *.ui file lies which you wish to convert to a *.py file.
So for instance, if you have a Qt designer file saved by the name untitled.ui on your desktop, put in the following command in your terminal:
Amars-MacBook-Pro:Desktop amaradak$ /usr/local/Cellar/pyqt/5.10.1_1/bin/pyuic5 -x untitled.ui -o untitled.py
Hope this helps...
Cheers
I am also a MAC user, but found adding the code below fixed my problem with "no module named sip":
from PyQt5.QtCore import QCoreApplication
On windows py3.10 with fresh venv it's throwing `No module named 'PyQt5.sip'.
pyqt5-sip is at version 12.9.1. After updating it (pip install pyqt5-sip -U) to version 12.11.0 it isn't throwing anymore.

Setting up a PyCharm environment for a GTK Hello World on Windows

I'm just trying to make a simple GTK Hello World app run in Pycharm.
I have installed PyCharm Community Edition 2016.2.
I have installed any combination of Anaconda (Python 2, Python 3, 32 bit, 64 bit).
I have downloaded a GTK hello world example
When I try to run this stuff, I first get the error
C:\Users\[...]\Anaconda3\python.exe C:/Users/[...]/PycharmProjects/HelloTk/hellotk.py
Traceback (most recent call last):
File "C:/Users/[...]/PycharmProjects/HelloTk/hellotk.py", line 3, in <module>
import pygtk
ImportError: No module named 'pygtk'
Which I tried to resolve by the instructions on SO: How do I import modules in Pycharm. However, this does not work for the error
Collecting PyGTK
Using cached pygtk-2.24.0.tar.bz2
Complete output from command python setup.py egg_info:
ERROR: Could not import dsextras module: Make sure you have installed pygobject.
Which brought me to the next step, installing pygobject. At first, this failed because of a missing pkg-config, which I installed according the instructions on Stack Overflow How to install pkg config in windows?. This seemed to work, but I now get the error
Collecting PyGObject
Using cached pygobject-2.28.3.tar.bz2
Complete output from command python setup.py egg_info:
* glib-2.0.pc could not be found, bindings for glib._glib will not be built.
ERROR: Nothing to do, glib could not be found and is essential.
Googling more, I found Installing PygObject via PIP in virtualenv, but the solution is for Linux only.
Since ~2h since I installed PyCharm and Anaconda I'm trying to compile a stupid simple Hello World program. How do I make it work and what was I doing wrong?
You need to download the latest installer for windows from: https://sourceforge.net/projects/pygobjectwin32/files/?source=navbar
Also, you must make sure you are not running python 3.5 or newer, the last supported version seems to be 3.4.x for GTK.
It took me a few hours to figure this out as the installer completes without complaining at all on 3.5 as well, it just doesn't install the package.
Regards,
Hunor
Edit: so, while this sort of works to install, i still can't get quite a few things to work in it :(

Pygame: Font module not available

Running Python 2.7.2, and Pygame 1.9.2pre on OS X.
Another noobious issue: Initialising the pygame.font module produces an error that I dare not... well, attempt to solve myself. I'm guessing this is a rather generic pygame-related issue... but I haven't been able to find any solutions.
import pygame
pygame.init()
pygame.font.init()
Gives:
Desktop/font.py:4: RuntimeWarning: use font: dlopen(/Library/Python/2.7/site-packages/pygame/font.so, 2): Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf
Reason: image not found
(ImportError: dlopen(/Library/Python/2.7/site-packages/pygame/font.so, 2): Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf
Reason: image not found)
pygame.font.init()
Traceback (most recent call last):
File "Desktop/font.py", line 4, in <module>
pygame.font.init()
File "/Library/Python/2.7/site-packages/pygame/__init__.py", line 70, in __getattr__
raise NotImplementedError(MissingPygameModule)
NotImplementedError: font module not available
(ImportError: dlopen(/Library/Python/2.7/site-packages/pygame/font.so, 2): Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf
Reason: image not found)
What exactly is wrong here? What are some possible reasons that the font module could not be available? Common causes? Common fixes?
If anyone can enlighten me about what's wrong, I'll appreciate it even if it doesn't solve the problem!
Thanks very much!
Edit: I am using 64 bit version of Python with 32 bit Pygame. (There seems to be no 64 bit Pygame available for Mac OS)
(self answer)
Problem: Using 32-bit Pygame with 64-bit Python generally isn't a good idea.
Solution: Always use Python and Pygame both in 64-bit architecture. (Or 32).
P.S. Currently there doesn't seem to be a 64-bit Pygame for OS X, so you'll have to use a 32-bit Python.
P.S.S (After installing a 32-bit Python you may need to re-install the 32-bit Pygame for it to have any effect. This is what happened to me)
I encounter the same problem, and the making-this-problem progress is as follow:
I download the pygame source file from the http://www.pygame.org/
I install the pygame with command python setup.py install
Then, I can import pygame and use basic pygame functions normally, but if I try to import other relative modules like import pygame.font, it jumps out font module not found error. I try to fix this problem by install some missing modules manually as suggested here:
$ sudo apt-get install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev
libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion
libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev
However, this problem still exists.
At last, I realize this is a dependency problem, so I remove installed pygame by the command sudo python setup.py clean and remove all files in python/site-packages. I reinstall the pygame by the command:
sudo apt-get install python-pygame
and everything works fine.

Problem using PySide / PyQt

I'm trying to install PySide to use the Qt libraries for scraping a website. I was following the instructions on this site and installed PySide using MacPorts (py26-pyside).
This command:
from PySide.QtCore import *
Works fine. But:
from PySide.QtGui import *
gives me this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PySide/QtGui.so, 2): Library not loaded: /opt/local/lib/libpng12.0.dylib
Referenced from: /opt/local/lib/libQtGui.4.dylib
Reason: Incompatible library version: libQtGui.4.dylib requires version 45.0.0 or later, but libpng12.0.dylib provides version 44.0.0
I've tried updating any old ports and reinstalling libpng through MacPorts, but no luck.
Any ideas what I need to do?
It not a good idea mix use system build-in python(version 2.6) and PySide install by manual.
I got the same problem before and fix it after upgrade to py27-pyside.
please try py27-pyside via MacPorts
sudo port install py27-pyside

Problems importing python-Xlib

I installed a new module and it appears as if one of its dependencies was not already installed. The module is called Xlib.display.
Here is the error message I received:
from Xlib.display import Display
ImportError: No module named Xlib.display
Where can I find this module that I am apparently lacking? Google yielded no leads.
"Edit: I already have that sourceforge module downloaded but I still get the same results.
Please try.
This shall install Xlib
sudo apt-get install python-xlib
Then you can check
>>from Xlib.display import Display
To install PyMouse if you want to control and capture mouse events please use:
sudo easy_install https://github.com/pepijndevos/PyMouse/zipball/master
Below worked for me!
pip install python3_xlib
I have also used pyuserinput for automation which requires this.
I was having the same problem, but the solutions above didn't work for me. Since I had installed python through the anaconda package, when I used:
sudo apt-get install python-xlib
Xlib was still undetectable by python2. The solution in my case was to use:
anaconda search -t conda python-xlib
Then find the package from the anaconda api, mine was erik/python-xlib. Install it using:
conda install --channel https://conda.anaconda.org/erik python-xlib
Then it worked.
On Debian systems install python-xlib.
On other systems there's a high probability that the package carries the same name.
I don't think the Xlib library works in Python 3.
Source:
Requirements
The Python X Library requires Python 1.5.2 or newer. It has been tested to various extents with Python 1.5.2 and 2.0 through 2.6.
I honestly cant explain why this works... but here is the command that got it working for me.
sudo apt-get install python3-xlib
Should not work because xlib apparently does not work with python 3.x, but everything installed alright, so I'm not complaining!
I was looking for the same answer, however after some more digging it seems that XCB (X protocol C-language Binding) will obsolete Xlib in general. From the XCB website:
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.
Fortunately there are python bindings available as python-xpyb in apt or xpyb on PyPi. I've not gotten that far in my project so I haven't tested if this works with Python3, but this is probably the way to go and the proper place to file any Python3 support bugs if necessary.
Scenario:
I was trying to use screenshot functionalities of pyautogui package. I was getting this error:
Traceback (most recent call last):
File "test_screenshot.py", line 1, in <module>
import pyautogui
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/__init__.py", line 152, in <module>
from . import _pyautogui_x11 as platformModule
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/_pyautogui_x11.py", line 7, in <module>
from Xlib.display import Display
ModuleNotFoundError: No module named 'Xlib'
Python code (test_screenshot.py):
import pyautogui
img = pyautogui.screenshot('test.png')
Environment:
Ubuntu 16.04 (LTS)
conda 4.5.11
Python 3.7 (Miniconda)
requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
PyTweening==1.0.3
Solution:
I installed python-xlib package in the conda environment using:
pip install python-xlib
Now test_screenshot.py is running without any error.
Updated requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
python-xlib==0.25
PyTweening==1.0.3
six==1.12.0

Categories

Resources