How to properly install PyGObject with Glade on OS X Mavericks - python

I'm using OS X Mavericks with system Python 2.7.
I installed PyGObject, GTK+ and glade as I descripted below, but Python doesn't see gtk.glade module.
All libraries from Homebrew:
brew install libglade
brew install gtk+
brew install pygobject
Also, I set PYTHONPATH in .bash_profile to:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
When I run Python and try import pygtk or gtk - all works fine. But when I try to load gtk.glade I get no module error.
So I'll try install pygobject with --verbose mode and I noticed, that installer couldn't find libglade:
checking for LIBGLADE... no
…
The following modules will be built:
atk
pango
pangocairo
gtk with 2.24 API
gtk.unixprint
The following modules will NOT be built:
gtk.glade
I assumed that pygobject installer can't find path to libglade (which is installed to /usr/local/Cellar/libglade/2.6.4).
How and what path should I change? Or what else to do?
Thanks in advance!

I had exactly the same problem and the following DID NOT work:
brew install --verbose --glade pygtk
But the following DID work on Mavericks with Python 2.7:
brew install --verbose --with-libglade pygtk
See also this discussion

PyGObject support for Gtk+2 is rater limited as Gtk+2 wasn't created with full Introspection support.
If you're using PyGobject don't use PyGtk, they are different things. In any case, why you need to use libglade? To support old Software? If that's the case, don't use PyGObject, use whatever version the Software was made with.
If you need to parse Glade files to build a GUI, use Gtk+ included GtkBuilder object, libglade was deprecated long long long long ago.
See gi.repository Windows, in particular differences with Gtk+2 and Gtk+3. Also, see How can a program that uses GUI be constructed? for how to build a Glade GUI using PyGObject, Python2.7 and GtkBuilder (this is what I suppose you need).

Need to include the "--glade" config option to Brew when installing, this causes the recipe/formula to make the bindings.
Need to install 'glade'; this will also install 'libglade'
Then install pygtk with the following option "brew install --glade pygtk"

Related

How do I link the ActiveState distribution of Tcl/Tk to HomeBrew installed Python

I am using macOS 10.12.1 Sierra. I am using Python 2.7.12 installed with
brew install python
but the IDLE gives the warning
WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.
and sure enough, it crashed frequently. 8.5.9 is the macOS preinstalled version.
I can download the stable 8.5.18 from the ActiveState website (as recommend by python, which works with the python installations from python.org (as they look for any other version of Tcl/Tk before resorting to the unstable macOS default 8.5.9).
However this download does not affect the brew installed python IDLE, which continues to use 8.5.9.
Is there anything I can do to link the updated Tcl/Tk with Homebrew, or can I install Tcl/Tk direct with homebrew?
I have also noticed that exactly the same problem happens when using anaconda python, which uses the preinstalled mac tcl/tk 8.5.9, not the user-installed tcl/tk 8.5.18
tcl-tk can be installed via Homebrew and one can have the Homebrew installed python linked to that version (Homebrew installed) of tcl-tk.
The only "barrier" to that, is to enable the right homebrew tap, as tcl-tk is not found in the "default" taps in Homebrew.
Indeed tcl-tk is found in the tap called homebrew-dupes which contain (cite the page)
formulae that duplicate software provided by macOS, though may provide more recent or bugfix versions.
Here the link to homebrew-dupes:
https://github.com/Homebrew/homebrew-dupes
and here the formula for tcl-tk
https://github.com/Homebrew/homebrew-dupes/blob/master/tcl-tk.rb
So the complete recipe to solve the problem would be:
Activate/Install the homebrew-dupes tap
Install tcl-tk
Install homebrew python using homebrew tcl-tk
The commands to be executed follow:
brew tap homebrew/dupes
brew install tcl-tk
brew install python --with-tcl-tk
Homebrew is an excellent package manager and while installing any package it is recommended to see the info.
brew info python
shows a lot of options that can be passed; but the most important one is
--with-tcl-tk
Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
I can think of a couple of messy solutions -
1) Insert the actual location of the installed module at the beginning of the path
import sys
sys.path.insert(1, 'YourTclLocation')
2) Append the new location and remove the previous location
import sys
sys.path.append('YourTCLLocation')
sys.path.remove('ProblemLocation')
import Tcl
3) Set PYTHONPATH environment variable in bash and make sure it doesn't have the broken location

Installing VMD with python support on MAC

I have been trying to install VMD1.9.2 on a Macbook with python support but have not been able to. It seems to me that the packaged .dmg file for VMD comes without Python support. I have used the command vmdinfo options to find the options my VMD is installed with and MACOSXX86 FLTKOPENGL FLTK TK ACTC CUDA IMD LIBSBALL LIBTACHYON VRPN NETCDF TCL PTHREADS SILENT this is the result which shows that it does not have Python support. My question- Is there an easy way to add python support rather than compiling from source? I just drag the App after unpacking the .dmg file to Applications folder. Am I doing something wrong while installing it this way? Is there any other way at all?
`
Robin Betz has created the vmd-python package. You can install it with conda:
conda install -c conda-forge vmd-python
More informations can be found in the package documentation.

How to install wxPython 3.0.2.0 on Ubuntu 14.04?

I am trying to install wxPython from src as I need the exact version 3.0.2.0 on Ubuntu. (So, I cannot follow the suggesion in the related question) I downloaded the source and did ./configure, make and make install. It seems to have ended without errors with the following message.
The installation of wxWidgets is finished. On certain platforms
(e.g. Linux) you'll now have to run ldconfig if you installed a
shared library and also modify the LD_LIBRARY_PATH (or equivalent)
environment variable. wxWidgets comes with no guarantees and
doesn't claim to be suitable for any purpose.
I confirmed my installation is not working by doing import wx & wx.version(). What needs to be done to complete the installation? Where should I set the LD_LIBRARY_PATH to?
Doing ./configure, make and make install only builds and installs wxWidgets. You also need to build wxPython using the build-wxpython.py script, which by default will also do the wxWidgets portion of the build for you, using known good configure flags. See wxPython/docs/BUILD.txt in the source tarball.
Try to check if wx is in sys.pah.
You can do it with this code
import sys
print sys.path
In output must be something like that /usr/lib/python2.7/dist-packages/wx
If not, adding path to wx folder to system path should solve your problem.
gtk3 should be install first
$sudo apt-get libgtk-3-dev
If you are facing problem to install wxpython on Python3 please use this command to install wxpython
$ pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython
By this command you can install latest wxPython4 version.
If you are using Windows or macOS
$ pip install -U wxpython
Older Version you can get from this link
https://sourceforge.net/projects/wxpython/files/wxPython/

Installing spyder python on windows 8

I would like to install spyder (the math IDE for python, here 2.7) on my windows 8.1 machine.
I did install python starting from http://www.python.org/download/releases/2.7.6/;
I did install pip after having installed setuptools, following http://www.pip-installer.org/en/latest/installing.html for these installations;
I did change my path to add C:\Python27 and C:\Python27\Scripts to it, digging into the advanced parameters of my PC's properties. (By the way, I can't beleive the way you do this on windows has not changed for ages, with such a small input where you forgot to go at the end of the value when adding your path...)
I did install spyder
pip install spyder
But when launching it in command line (it's in the path :-) ), I ran through this error:
RuntimeError: Please check Spyder installation requirements:
PyQt4 4.4+ (or PySide 1.1.1+) is required.
Which is truly true. Though,
when trying to pip PyQt4 :
No distributions at all found for PyQt4
when trying to pip PySide, I have many errors, the root one seeming that it is unable to find nmake
Any piece of advice ?
To install PySide on Windows you can choose from the following options:
Download and install the packages from the releases page.
Use setuptools to install the egg binary packages:
c:> c:\Python27\Scripts\easy_install PySide
Use pip to install the wheel binary packages:
c:> c:\Python27\Scripts\pip install --use-wheel PySide
Details are here https://pypi.python.org/pypi/PySide#installing-pyside-on-a-windows-system
BTW: PyQt does not support setuptools or pip
I am not sure if its a proper answer, but you might want to take a look at PythonXY. It makes all these installation procedure a breeze.
From the details in your question, it looks like you are missing both PyQt4 and Qt itself.
There are binary installers for Windows available from the PyQt download page. These installers include both PyQt and Qt (as well as various other tools such as Qt Designer). The only things not included are the Qt documentation, and Python itself (which you seem to have already installed).
Just be careful to select the right installer from the list of Binary Packages: i.e. the one for Python-2.7, plus whatever architecture is appropriate for your system.

I want to use matplotlib in osx lion

I installed matplotlib from macports, and version of python is 2.7.1.
$ sudo port install py27-matplotlib py27-matplotlib-basemap
I wrote a sample program below.
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pylab import *
plot([1,2,3])
show()
But this didn't work correctly with error log "no module named pylab".
And I tried easy_install.
$ sudo easy_install matplotlib
In this case, my program worked correctly with no errors.
What is the difference between these two cases(macports and easy_install)?
I think the version of matplotlib is same in two cases.
In case of macports, do I have to redefine include path?
Would you help me??
To ensure a compatible environment, MacPorts Python packages automatically install a MacPorts Python. By default, you can invoke it via /opt/local/bin/python2.7. And that's where you will find the MacPorts installed matplotlib et al. /usr/bin/python will invoke the Apple-supplied system Python 2.7.1 and, when you ran sudo easy_install you were using the Apple-supplied easy_install command associated with the system Python. That means you now have two Python 2.7 instances installed, each with a separate version of matplotlib. There's nothing wrong with that but you probably want to stick with one or the other. You can make the MacPorts Python 2.7 be your default by ensuring your SHELL path has /opt/local/bin before /usr/bin and by using the MacPorts port select python python27 command.
As mentioned by Ned Deily, the problem is caused because MacPorts installs a separate Python even though OS X ships its own version.
I would suggest you use Homebrew instead of MacPorts to avoid problems like this. Homebrew will use the available package on OS X when possible.
Another suggestion is that it's better to use pip to manage Python package, which is a replacement for easy_install and supports uninstalling packages. The benefit of using packaging system (like MacPorts, Debian's apt) to manage python package is that they can solve the dependency if the Python package relies on other C libraries. But in case the some Python packages are not included in MacPorts or apt, you will need to resolve to easy_install or pip. And it's usually not a good idea to use two packaging system to manage your python package at the same time.

Categories

Resources