Opened 9 years ago
Closed 9 years ago
#50536 closed defect (worksforme)
py27-gobject3 @3.18.2_0 "Cannot import GtK"
Reported by: | nek2626@… | Owned by: | macports-tickets@… |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.3.4 |
Keywords: | Cc: | ||
Port: | py-gobject3 |
Description (last modified by mf2k (Frank Schima))
Using OS X 10.9.5. At one point I had the following imports working in python:
import gi from gi.repository import GtK, GObject, Gdk
A little backstory: I was poking around in my Python.frameworks files for gi because of an unrelated issue with GtK and matplotlib. I opened some files in emacs, one sent up a warning about local variables to which I think I may have responded yes. After this poking around, I was no longer able to import GtK and Gdk. I instead got the errors:
ImportError: cannot import name GtK ImportError: cannot import name Gdk
I uninstalled py27-gobject3 and attempted to reinstall it to no avail. I also tried uninstalling with --follow-dependencies" and then reinstalling, again with no luck. During one uninstall I noted that the original gi directory I was in in ../Python.framworks/ was no longer there. I've been trying my hand at multiple fixes, including seeing this ticket - ticket:40179 - saying I should also have gtk3 installed, which did not help. I'm super lost at this point if it's something wrong with the installer or what. I'm also not sure if there is any further information that would be useful to help diagnose this issue.
(py27-gobject3 was listed as open maintainer, so I didn't include a cc to any maintainer).
Change History (5)
comment:1 Changed 9 years ago by mf2k (Frank Schima)
Keywords: | python GtK removed |
---|---|
Owner: | changed from macports-tickets@… to cal@… |
Port: | py-gobject3 added; py27-gobject3 gtk3 removed |
comment:2 Changed 9 years ago by mf2k (Frank Schima)
Description: | modified (diff) |
---|
comment:3 Changed 9 years ago by neverpanic (Clemens Lang)
Owner: | changed from cal@… to macports-tickets@… |
---|
If a port has no maintainer, it wouldn't contain 'openmaintainer' but 'nomaintainer'.
Unfortunately there's is nothing in this ticket for me to act on. Please make sure you are using the right Python (/opt/local/bin/python2.7) and add a console log showing the problem in detail if it keeps happening with the correct python interpreter.
Also, as of r145450 I no longer maintain py27-gobject3.
comment:4 Changed 9 years ago by dbevans (David B. Evans)
Summarizing from above you need to make sure that you are not using Mac OS X system python (which goes not have gi
, etc installed) but instead are using MacPorts python27 (which is where py27-gobject3
installs gi
). It is also true that you need gtk3
installed if you wish to import Gtk
and/or Gdk
.
You can make python27
your default python
(the one that is invoked when you type python
and/or python2
) by following the instructions that are suggested when installing python27
:
$ port notes python27 python27 has the following notes: To make this the default Python or Python 2 (i.e., the version run by the 'python' or 'python2' commands), run one or both of: sudo port select --set python python27 sudo port select --set python2 python27
Assuming neither py27-gobject3
nor gtk3
are installed, the following sequence of commands works for me:
$ sudo port install py27-gobject3 gtk3 $ sudo port select --set python python27 Selecting 'python27' for 'python' succeeded. 'python27' is now active. $ python Python 2.7.11 (default, Dec 5 2015, 23:52:42) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>> gi.require_version('Gdk', '3.0') >>> gi.require_version('Gtk', '3.0') >>> from gi.repository import Gdk, GObject, Gtk >>>
Note that, as of py27-gobject3 3.18.0
, use of
>>> gi.require_version('Gdk', '3.0') >>> gi.require_version('Gtk', '3.0')
is necessary to avoid warning messages similar to the following:
>>> from gi.repository import Gtk, GObject, Gdk >>> __main__:1: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded. >>>
Hope this helps
comment:5 Changed 9 years ago by dbevans (David B. Evans)
Resolution: | → worksforme |
---|---|
Status: | new → closed |
No response for almost a week, so I'll assume that the reporter's issue has been solved.
Per the guidelines, please Cc the port maintainer in the future, otherwise (s)he won't likely see the ticket and your issue will not be addressed.