Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PySide on Mac: is there a working method?

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?

like image 220
fralau Avatar asked Jan 04 '17 20:01

fralau


People also ask

What is PySide package?

PySide is a Python binding of the cross-platform GUI toolkit Qt developed by The Qt Company, as part of the Qt for Python project. It is one of the alternatives to the standard library package Tkinter. Like Qt, PySide is free software. PySide supports Linux/X11, macOS, and Microsoft Windows.

Is PySide2 open source?

PySide2 is available under both Open Source (LGPLv3/GPLv2) and commercial license.

Does PySide2 work on Linux?

The simplest way to install PySide2 on Linux is to use Python's pip packaging tool, just as for other packages. For Python3 installations this is usually called pip3 . After install is finished, you should be able to run python (or python3 ) and import PySide2 without errors.


2 Answers

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
like image 178
Yuva C Avatar answered Sep 23 '22 13:09

Yuva C


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

like image 24
minigeek Avatar answered Sep 24 '22 13:09

minigeek