How to install pygtk 3 on Mac OS X?

后端 未结 4 1298
醉梦人生
醉梦人生 2020-12-20 21:13

What I tried:

brew install pygobject3 --with-python@2 gtk+3
brew install pygtk3
brew install pygobject3
pip install pygobject

python -c \'import gi; gi.requ         


        
相关标签:
4条回答
  • 2020-12-20 21:38

    I had the same problem. I followed the instructions on pygobject web.

    • install homebrew
    • Execute brew install pygobject3 --with-python@2 gtk+3
    • Run python3 hello.py

    Everything is fine now (note I use python3 not python for the test) :

    $ python3 -c 'import gi; gi.require_version("Gtk", "3.0"); print("ok")'
    ok
    
    0 讨论(0)
  • 2020-12-20 21:39

    install the gtk3 distribution version from Conda-forge channel

    https://github.com/conda-forge/gtk3-feedstock/tree/cb80587f33166c0e19abe20ea7885a03bffda4ab

    0 讨论(0)
  • 2020-12-20 21:44

    The problem is that the developers of pygobject3 have written their install instructions that does NOT consider pip/conda. If you follow the official documentation:

    • Have to use the homebrew python installation (the one installed when you go brew install python)
    • brew install gtk+3 is NOT compatible with non homebrew Pip/Conda python installs. You have to build the GTK3 package manually to use the pip version of pygobject3.

    However if you want to use conda, thanks to this conda contributor, there is a pre-built conda gtk3 package you can use, you just have to get it from his channel:

    Make a new environment using conda:

    conda create --name my_env
    

    install pygobject3 from conda

    conda install pygobject
    

    install gtk3 from the pkgw-forge channel

    conda install -c pkgw-forge gtk3
    

    To verify, open python from within the conda env and run

    import gi
    gi.require_version("Gtk", "3.0")
    

    Should get no errors

    0 讨论(0)
  • 2020-12-20 21:59

    I had the same problem. I tried

    $ brew install pygobject3 gtk+3

    and it was smoothly installing. Then checked as Jeff's answer:

    $ python3 -c 'import gi; gi.require_version("Gtk", "3.0"); print("ok")'

    got ok.

    Hope this helps,

    Cheers

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