Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to install on windows #5

Closed
tolomea opened this issue Jun 8, 2012 · 14 comments
Closed

fails to install on windows #5

tolomea opened this issue Jun 8, 2012 · 14 comments

Comments

@tolomea
Copy link

tolomea commented Jun 8, 2012

Trying to install this on a win7 machine I get the following stack:

$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 20, in
from gtkspellcheck import version
File "c:\code\pygtkspellcheck\src\gtkspellcheck__init__.py", line 37, in
import gtk
File "c:\python27\lib\site-packages\gtk-2.0\gtk__init__.py", line 30, in
import gobject as gobject
File "c:\python27\lib\site-packages\gtk-2.0\gobject__init
_.py", line 26, in
from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds,
File "c:\python27\lib\site-packages\gtk-2.0\glib__init__.py", line 22, in
from glib._glib import *
ImportError: DLL load failed: The specified procedure could not be found.

here's some version info

$ python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

import gtk
gtk.ver
(2, 28, 3)

Any suggestions about what might be going wrong?

@koehlma
Copy link
Owner

koehlma commented Jun 9, 2012

Hmmm... I searched a little bit:
http://stackoverflow.com/questions/6079685/what-is-wrong-with-my-windows-gtk-for-python-installation
Have you tried this so far?
Because I have no Windows 7 installation at the moment I can't test this my self.

@tolomea
Copy link
Author

tolomea commented Jun 13, 2012

Yeah, and various other variations on that theme, none of which helped, although remarkably I don't seem to have broken my system yet. Perhaps I should give up and setup a linux virtual machine.

@tolomea
Copy link
Author

tolomea commented Jun 13, 2012

The odd thing and what I suspect is the key to this mess, is that I can import gtk from the python prompt with no problems.
It's only when running your setup.py that it fails.

@tolomea
Copy link
Author

tolomea commented Jun 13, 2012

It seems to be the import of enchant, if I comment that out of init.py then the setup install runs and I fail at runtime with:

Traceback (most recent call last):
File "main.py", line 12, in
from gtkspellcheck import SpellChecker, languages, language_exists
ImportError: cannot import name languages

@tolomea
Copy link
Author

tolomea commented Jun 13, 2012

putting the enchant import after the gtk import has the same effect as commenting it out, specifically the languages import error above, here's the enchant version if that helps any

C:\code\blog>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import enchant
enchant.version
'1.6.5'

@koehlma
Copy link
Owner

koehlma commented Jun 13, 2012

If you are using the newest version, there was an API change.
There is no language list and language_exists on module level anymore.
Please check the documentation http://koehlma.github.com/pygtkspellcheck/ or the new example.
There is a languages attribute for every SpellCheck instance because the list can vary if you set for example a different dictionary directory for each enchant.Broker.
So, adapt your application and try it again with the enchant import behind the gtk import.
What happens?

@tolomea
Copy link
Author

tolomea commented Jun 14, 2012

Yeah, that got me past the pygtkspellcheck specific problems, now I'm just bashing up against not having gi.repository which has broken all of my code. I'm not clear why I don't have that or even if I'm supposed to have it, do you know anything about gi.repository on windows?

@koehlma
Copy link
Owner

koehlma commented Jun 14, 2012

There is no GObject-Introspection for windows yet.
(Except if you use Cygwin - if I remember right)

You have to backport your application to PyGTK.
Indeed you have to maintain 3 versions of your application - like pygtkspellcheck does.
PyGTK with Gtk 2, GObject-Introspection with Gtk 2 and GObject-Introspection with Gtk 3.

@tolomea
Copy link
Author

tolomea commented Jun 14, 2012

awesome, that's going to be a touch tedious, thanks for the help, I'll let you know how it goes

koehlma pushed a commit that referenced this issue Jun 14, 2012
@koehlma
Copy link
Owner

koehlma commented Jun 14, 2012

I fixed the import issue, now you only have to backport your application - good luck

@koehlma koehlma closed this as completed Jun 14, 2012
@tolomea
Copy link
Author

tolomea commented Jun 14, 2012

I have the backport done and everything seems to be working fine, including the spell checking. Having done my backport I'm curious about a couple of things in yours.

    if _gobject:
        menu = gtk.Menu.new()
    else:
        menu = gtk.Menu()

Under gobject I don't use the new function in places like this, I just call the default constructor, so I don't need the if statement at all, is this required for a gobject 2/3 difference? or is it redundant?

window = gtk.Window.new(gtk.WindowType(0))

Why is the gtk.WINDOW_TOPLEVEL constant not used here instead of the explicit 0?

@tolomea
Copy link
Author

tolomea commented Jun 14, 2012

btw, thanks for your help and for creating the spellchecker in the first place

@koehlma
Copy link
Owner

koehlma commented Jun 15, 2012

I think code says more than thousand words:

if _gobject:
    menu = gtk.Menu.new()
else:
    menu = gtk.Menu()

>>> gtk.Window(gtk.WindowType.TOPLEVEL)                                                                                                                                                                                                      
Traceback (most recent call last):                                                                                                                                                                                                           
  File "<stdin>", line 1, in <module>                                                                                                                                                                                                        
TypeError: GObject.__init__() takes exactly 0 arguments (1 given)                                                                                                                                                                            
>>> gtk.Window.new(gtk.WindowType.TOPLEVEL)                                                                                                                                                                                                  
<Window object at 0x1e3fe60 (GtkWindow at 0x1ecf090)> >>> gtk.Window(gtk.WindowType.TOPLEVEL) 

(the new method is like the original C method - http://developer.gnome.org/gtk3/stable/ - sometimes it works without new and sometimes not, so I decided to use new everytime)

There is no gtk.WINDOW_TOPLEVEL constant over gi.repository.

>>> gtk.WINDOW_TOPLEVEL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.2/site-packages/gi/module.py", line 243, in __getattr__
    return getattr(self._introspection_module, name)
  File "/usr/lib/python3.2/site-packages/gi/module.py", line 105, in __getattr__
    self.__name__, name))
AttributeError: 'gi.repository.Gtk' object has no attribute 'WINDOW_TOPLEVEL'
>>> gtk.WindowType(0)
<enum GTK_WINDOW_TOPLEVEL of type GtkWindowType>

But I think I could use gtk.WindowType.TOPLEVEL instead (or do you mean this by gtk.WINDOW_TOPLEVEL).

@tolomea
Copy link
Author

tolomea commented Jun 15, 2012

(the new method is like the original C method -
http://developer.gnome.org/gtk3/stable/ - sometimes it works without new
and sometimes not, so I decided to use new everytime)

I understand that reasoning, I took the opposite approach of only using new
where it was required in order to minimise the number of places where I
switch on _gobject

gtk.WINDOW_TOPLEVEL

I may have confused things here, this was not about sharing code between
gobject and gtk, it was purely about gtk style, I see you've changed it now.

On Fri, Jun 15, 2012 at 6:06 PM, koehlma <
reply@reply.github.com

wrote:

I think code says more than thousand words:

if _gobject:
menu = gtk.Menu.new()
else:
menu = gtk.Menu()

gtk.Window(gtk.WindowType.TOPLEVEL)
Traceback (most recent call last):
File "", line 1, in
TypeError: GObject.init() takes exactly 0 arguments (1 given)
gtk.Window.new(gtk.WindowType.TOPLEVEL)
<Window object at 0x1e3fe60 (GtkWindow at 0x1ecf090)> >>>
gtk.Window(gtk.WindowType.TOPLEVEL)

(the new method is like the original C method -
http://developer.gnome.org/gtk3/stable/ - sometimes it works without new
and sometimes not, so I decided to use new everytime)

There is no gtk.WINDOW_TOPLEVEL constant over gi.repository.

gtk.WINDOW_TOPLEVEL
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.2/site-packages/gi/module.py", line 243, in
getattr
return getattr(self._introspection_module, name)
File "/usr/lib/python3.2/site-packages/gi/module.py", line 105, in
getattr
self.name, name))
AttributeError: 'gi.repository.Gtk' object has no attribute
'WINDOW_TOPLEVEL'
gtk.WindowType(0)

But I think I could use gtk.WindowType.TOPLEVEL instead (or do you mean
this by gtk.WINDOW_TOPLEVEL).


Reply to this email directly or view it on GitHub:
#5 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants