Installing PySide on Mac: is there a working method?

前端 未结 6 1592
离开以前
离开以前 2021-02-06 08:06

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 prec
相关标签:
6条回答
  • 2021-02-06 08:14

    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.

    0 讨论(0)
  • 2021-02-06 08:22

    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

    0 讨论(0)
  • 2021-02-06 08:23

    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
    0 讨论(0)
  • 2021-02-06 08:24

    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 讨论(0)
  • 2021-02-06 08:28

    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

    0 讨论(0)
  • 2021-02-06 08:31

    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.

    0 讨论(0)
提交回复
热议问题