7

I may be doing something wrong, but I have been trying to install pyside on Mac 10.12 (Sierra). Here is what I tried (after installing Qt with brew):

  • With the precompiled package (1.2.1); fails because of "incompatible package".
  • With sudo -H pip install pyside (1.2.4): fails with the following error:
 Qt QTGUI library not found.
 Qt QTXML library not found.
 Qt QTCORE library not found.
 CMake Error at ApiExtractor/CMakeLists.txt:82 (qt4_add_resources):
  Unknown CMake command "qt4_add_resources".
  • With brew install pyside==1.2.2 : works successfully but when calling it from a python program, fails with ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Libmrary not loaded: libpyside-python2.7.1.2.dylib Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so Reason: unsafe use of relative rpath libpyside-python2.7.1.2.dylib in /Library/Python/2.7/site-packages/PySide/QtCore.so with restricted binary

The last one did offer some hope, and I tried PySide import error Mac OS X El Capitan, Library not loaded: @rpath/libpyside.cpython-34m.1.2.dylib . Unfortunately, the explanation was quite elliptic and I ended up breaking things further.

Am I missing something obvious? The fact that the precompiled packages are old and the web doc is not updated, that brew install does not seem to work (and the documentation makes no mention of it) and generally number of questions asked about pyside and the technical complication of the answers do not seem very good signs.

Does someone know what the matter is with PySide's installation on Mac OS, technically? What's the best solution in my particular case?

More generally, is there hope for improvement with PySide on Mac?

Update (25 Jan 2017): Workaround?

Since we are waiting for an update from Pyside, is someone willing to take the challenge of installing 1.2.2 on OS Sierra with brew, and resolve the "unsafe use of relative path"? Perhaps propose a step-by-step tutorial?

That might save the day for PySide on Mac... while relieving the time pressure on the Pyside development team?

Community
  • 1
  • 1
fralau
  • 3,279
  • 3
  • 28
  • 41

6 Answers6

6

I have MAC osSierra (10.12.6). I needed to install PySide 1.2.4 for Python 3.3.6. I did the following to build and install PySide 1.2.4 that I need. You can do the following for any Python 3.3.x, I guess.

I am a newbie to Mac and Python. Please ignore if I have any mistakes.

  • Install pyenv
    brew install pyenv
  • Install Python 3.3.6 using pyenv
    pyenv install 3.3.6
  • Add python 3.3.6 into system path
    PATH="/Users/myname/.pyenv/versions/3.3.6/bin:${PATH}"
    export PATH
  • Install Xcode from app store, then run the following. Xcode download and install took 30-40 minutes for me.
    xcode-select --install
    sudo xcodebuild -license
  • Install cmake
    brew install cmake
  • Verify cmake is installed. I see version 3.10.0 installed
    cmake —version
  • Tap qt4. Note: I tried qt5, but pyside build is not working for me with qt5.
    brew tap cartr/qt4
    brew tap-pin cart/qt4
  • Install qt@4.
    brew install qt@4
  • Verify qmake is installed. I see version 2.01a installed
    qmake —version
    (If qmake is not recognized, create links to it using below command)
    brew link cartr/qt4/qt@4 —-force
  • If you are using “PySide.QtWebKit” in your programs, you need to install qt-webkit. Install pyside (1.2.2 ??), which will install qt-webkit. I am not sure if qt-webkit can be installed directly, if so someone can correct me.
    brew install pyside
  • Download PySide 1.2.4 tar file.
    wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz
  • Untar the tar file
    tar -xvf PySide-1.2.4.tar.gz
  • Go into the folder
    cd PySide-1.2.4
  • Build pyside. This build step took almost 30-40 minutes for me
    python setup.py bdist_wheel
  • Verify that “dist” folder is created and it has pyside wheel file in it.
  • Go into the “dist” folder
    cd dist
  • Instal PySide, last step!!
    pip install PySide-1.2.4-cp33-cp33m-macosx_10_12_x86_64.whl
  • Congratulations!, now you have PySide 1.2.4 for Python 3.3.x
Yuva C
  • 61
  • 1
  • 4
  • 1
    This was super helpful! A couple of notes, I installed for Python 2.7, and I didn't have wheel, so I needed to `pip install wheel` before I could `python setup.py bdist_wheel`. I also needed to `brew install wget`, although I appreciate I could just have downloaded PySide through the browser using your link. – Philip Scadding Sep 26 '18 at 10:26
1

This isn't the answer but unfortunately there has not been any output from pyside team for macOS sierra .Only supported OS from apple are

  • 10.6 Snow LeopardOS X

  • 10.7 LionOS X

  • 10.8 Mountain LionOS X

  • 10.9 MavericksOS X

  • 10.10 Yosemite

Update : (You can try this still )

 curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/fdfc724dd532345f5c6cdf47dc43e99654e6a5fd/Formula/qt5.rb

 brew install ./qt5.rb

If above lines doesn't work :

You’ll need the Xcode commandline tools:

  xcode-select --install sudo xcodebuild -license 

Then the following packages can be easily installed via brew:

  brew install qt5 cmake libxslt libxml2 

This will install Qt 5.6.1-1 and cmake 3.5.2 your system

Now time to clone ! Not from github but from this link : So Clone the pyside-setup repository and have it also pull down its gitmodules:

 git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup

This command worked fine for people using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.

 python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin

(Note : The exact paths given in the arguments may not be identical on your system so verify those prior to compiling)

Install the wheel :

A wheel was hopefully built in the dist folder. So just cd dist and pip install away!

Notes on pre-compiled wheels

Unfortunately, and like with PySide, these wheels are not “portable” and won’t install on systems which doesn’t already have the specific Qt5 version installed used during compilation. This, I believe, is because PySide2 links dynamically (instead of statically) against the Qt5 installation. Hopefully, this is something The Qt Company will address via official PySide2 wheels, as Riverbank Software is now providing a fully portable PyQt5 wheel for Python 3 which is absolutely awesome.

New Repository (not from github)

Reference

minigeek
  • 2,766
  • 1
  • 25
  • 35
  • Interestingly I had a version of Pyside (1.2.4) on another Mac that works on OSSierra. But it was likely installed from a previous version of Mac and survived the upgrade... – fralau Jan 22 '17 at 10:21
  • Oh thats cool @fralau sierra might be missing some libraries when newly installed ..upgrade might let the unnecessary packages in the system itself..#maybe – minigeek Jan 22 '17 at 10:27
  • @fralau can you recheck the answer? I updated it..let me know – minigeek Jan 28 '17 at 18:37
  • I'll check it tomorrow -- I let you know. – fralau Jan 29 '17 at 20:54
  • So far so good, it compiled! But I have got this: "python test16.py Traceback (most recent call last): File "test16.py", line 12, in from PySide import QtCore, QtGui, QtSql ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Library not loaded: libpyside-python2.7.1.2.dylib Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so Reason: unsafe use of relative rpath libpyside-python2.7.1.2.dylib in /Library/Python/2.7/site-packages/PySide/QtCore.so with restricted binary" – fralau Jan 30 '17 at 19:21
  • Huh :/ check the reference link I provided in the answer in last..in the blog check comments too may b that can solve your problem ! Remember its not supported on github anymore ! Let me know again @fralau bcoz that guy installed it in os sierra – minigeek Jan 31 '17 at 03:58
  • OK, now I get the official repository is not maintained any longer at GitHub but at the website of Qt, and that is called "Pyside2". Nevertheless, I am back at square 1 with the error on relative paths (unless there is something wrong with links on python or libraries). I believe *that* is an issue of OS Sierra. – fralau Jan 31 '17 at 09:16
1

The Mac steps from here worked for me: https://fredrikaverpil.github.io/2016/08/17/compiling-pyside2/

You’ll need the Xcode commandline tools:

xcode-select --install
sudo xcodebuild -license

Then the following packages, easily installed via brew:

brew install qt5 cmake libxslt libxml2

Clone the pyside-setup repository and have it also pull down its gitmodules:

git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup

Build it. This command worked fine for me using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.

cd pyside-setup
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin

Last but not least, install the wheel:

cd dist
pip install PySide2-2.0.0.dev0-cp27-cp27m-macosx_10_12_x86_64.whl

All credits go to Fredrik Averpil's wonderful post.

Tiago
  • 1,984
  • 1
  • 21
  • 43
  • That helped me. However, the "5.6.1-1" part in the "python setup.py ..." command needed to be updated to the actually installed qt5 version. -- Uh, I spoke too soon. The build process stopped with "error: Qt requires a C++11 compiler and yours does not seem to be that." – Thomas Tempelmann Mar 15 '17 at 14:31
  • 2
    I had problems with different QT versions, if I remember right. The whole pyqt setup is a frustrating mess. – Tiago Mar 15 '17 at 20:43
  • Alas, it failed on the python setup.py step: fatal error: too many errors emitted, stopping now [-ferror-limit=] 3 warnings and 20 errors generated. make[2]: *** [plugins/CMakeFiles/uiplugin.dir/customwidgets.cpp.o] Error 1 make[1]: *** [plugins/CMakeFiles/uiplugin.dir/all] Error 2 make: *** [all] Error 2 error: Error compiling pyside2 – fralau Apr 25 '17 at 20:29
  • @fralau there's probably a more detailed error further up before that. – Tiago Apr 27 '17 at 07:34
1

You need a specific version of Qt and pyside.

Install both the QT 4.8.5 package as well as pyside from the Mac installers on the page below:

https://wiki.qt.io/PySide_Binaries_MacOSX

1

You need QT4 to install PySide on 10.11 (not sure about 10.12).

Install QT5 either via Brew or via installer, get cmake via brew and get the latest PySide source (https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz) Run the following to get Qt4:

brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt_4

Once you do so; cd in the source folder and run the following to build:

python setup.py bdist_wheel --ignore-git --qmake=[QMAKE_FROM_QT4_PATH] --cmake=[YOUR_CMAKE_PATH]

cd dist
pip install [YOUR_BUILT_PYSIDE_WHEEL]

Once you do so, you can check that PySide is working correctly, opening a Python console and typing import PySide

0

I still not have a solution, but I found an alternative.

First of all, I am not an expert (I am super new coding). Based on my own experience below you will find a solution as well.

I need to clarify something first, there are two ways to use this GUI QT - PyQt by Riverbank Computing or(and) PySide, originally developed by Nokia.

I tried many differents ways to install PySide on my MacOS Sierra version10.12.5, but no success, so I ended up finding PyQt, that does the same thing.

Watching this video I installed the PyQT5 in my Mac OS and now it is working. https://www.youtube.com/watch?v=2kHk8ZjxH64

Example of Hello World using PyQT http://pythoncentral.io/intro-to-pysidepyqt-basic-widgets-and-hello-world/

The wiki.qt.io says "PySide has included support for Python 3.2 since version 1.0.8." but it doesn't work for me.

Good lucky.

Thiago Farias
  • 301
  • 2
  • 7
  • These links may help to get some solution , it is better to include the essential parts of the answers here and provide the link for reference. – Nipun Aug 03 '17 at 10:58
  • Sorry, I am new here. I will fix it and do it properly. Thank you Nipun. – Thiago Farias Aug 03 '17 at 11:17