Pages: [1]
  Print  
Author Topic: Trouble getting started  (Read 3456 times)
Boco
Apprentice
*
Posts: 7


View Profile
« on: February 16, 2010, 03:27:30 AM »

I keep getting errors after downloading libtcodpy and adding it to my src folder. I'm using Netbeans and have been for a while, but this error keeps popping up when I try to use libtcodpy.

Code:
Traceback (most recent call last):
  File "C:\Users\Boco\Documents\NetBeansProjects\pyrl\src\pyrl.py", line 2, in <module>
    import libtcodpy as libtcod
  File "C:\Users\Boco\Documents\NetBeansProjects\pyrl\src\libtcodpy.py", line 41, in <module>
    _lib = ctypes.cdll['./libtcod-mingw.dll']
  File "c:\Python26\lib\ctypes\__init__.py", line 428, in __getitem__
    return getattr(self, name)
  File "c:\Python26\lib\ctypes\__init__.py", line 423, in __getattr__
    dll = self._dlltype(name)
  File "c:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

Any idea what this is all about?

edit: Probably should have mentioned that this is on Win7 x64. I have the python directory added to the global PATH, and minGW is installed. Python v2.6.4 amd64, and the latest libtcodpy (1.5.0)
« Last Edit: February 16, 2010, 04:26:26 AM by Boco » Logged
george
Master
****
Posts: 216


View Profile
« Reply #1 on: February 16, 2010, 04:36:11 AM »

How are you launching the python script (i.e. what is the Netbeans command doing). %1 makes me think there's something wrong there, as usually that is a stand-in for the argument to a command line execution.

edit: minGW wouldn't be the issue here, you just need the .dll.
Logged
Boco
Apprentice
*
Posts: 7


View Profile
« Reply #2 on: February 16, 2010, 05:33:53 AM »

How are you launching the python script (i.e. what is the Netbeans command doing). %1 makes me think there's something wrong there, as usually that is a stand-in for the argument to a command line execution.

edit: minGW wouldn't be the issue here, you just need the .dll.

That's what I thought as well. However, I tried running the script from the command prompt "python pyrl.py" and it outputs the same error:

Code:
C:\Users\Boco\Documents\NetBeansProjects\pyrl\src>python pyrl.py
Traceback (most recent call last):
  File "pyrl.py", line 2, in <module>
    import libtcodpy as libtcod
  File "C:\Users\Boco\Documents\NetBeansProjects\pyrl\src\libtcodpy.py", line 41, in <module>
    _lib = ctypes.cdll['./libtcod-mingw.dll']
  File "C:\Python26\lib\ctypes\__init__.py", line 428, in __getitem__
    return getattr(self, name)
  File "C:\Python26\lib\ctypes\__init__.py", line 423, in __getattr__
    dll = self._dlltype(name)
  File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

I also tried python -u pyrl.py which has the same results. Reinstalling Python did not change anything either.
« Last Edit: February 16, 2010, 05:41:53 AM by Boco » Logged
george
Master
****
Posts: 216


View Profile
« Reply #3 on: February 16, 2010, 06:11:22 AM »

I just tried a couple of things here but can't pin this down...maybe someone else using 1.5 Python can comment?

Feel free to create a minimal example and attach it too, I could try to run your file here.   Actually I'm on Win 32, not sure if that would help.
Logged
Boco
Apprentice
*
Posts: 7


View Profile
« Reply #4 on: February 16, 2010, 06:37:18 AM »

I just tried a couple of things here but can't pin this down...maybe someone else using 1.5 Python can comment?

Feel free to create a minimal example and attach it too, I could try to run your file here.  Actually I'm on Win 32, not sure if that would help.

Heres the code that I've been trying to run unsuccessfully. It's just code from the koonieform wordpress blog, perhaps a slight bit different, but not much.

Code:
import libtcodpy as libtcod
import os

def setup():
    window_width = 46
    window_height = 20
    first = True
    fov_px = 20
    fov_py = 10
    fov_recompute = True
    fov_map = None
    fov_colors = {
        'dark wall' : libtcod.Color(0, 0, 100),
        'light wall': libtcod.Color(130, 110, 50),
        'dark ground': libtcod.Color(50, 50, 150),
        'light ground': libtcod.Color(200, 180, 50)
        }
    fov_init = False
    fov_radius = 4

    move_controls = {
        'i' : (0, -1), #UP
        'k' : (0, 1),  #DOWN
        'j' : (-1, 0), #LEFT
        'l' : (1, 0)   #RIGHT
        }

def main():
    setup()


if __name__ == "__main__":
    main()

As a sidenote, I've tried creating a new .py file and importing the libtcodpy library and I get the same error.

Code:
import libtcodpy as libtcod

def main():
     x = 5

if __name__ == '__main__':
     main()
« Last Edit: February 16, 2010, 06:47:28 AM by Boco » Logged
george
Master
****
Posts: 216


View Profile
« Reply #5 on: February 16, 2010, 07:07:21 AM »

...it comes back to haunt me (kooneiform is mine btw  Cheesy).

OK, your minimal main() example works for me. What is the directory structure of your project?
Logged
Boco
Apprentice
*
Posts: 7


View Profile
« Reply #6 on: February 16, 2010, 07:18:39 AM »

...it comes back to haunt me (kooneiform is mine btw  Cheesy).

OK, your minimal main() example works for me. What is the directory structure of your project?

Koonieform is yours? Seems like a well done example. Thank you for sharing it. I hope I can get this working to actually make use of it.

Code:
+Documents
 +NetBeansProjects
  +Pyrl
    libtcod-gui-mingw.dll
    libtcod-gui-mingw-debug.dll
    libtcod-mingw.dll
    libtcod-mingw-debug.dll
    SDL.dll
   +src
    libtcodpy.py
    libtcod-gui-mingw.dll
    libtcod-gui-mingw-debug.dll
    libtcod-mingw.dll
    libtcod-mingw-debug.dll
    pyrl.py
    SDL.dll

Everything appears to be there. I'm not sure if the debug or SDL dll's are required.
Logged
Scautura
Guardian
**
Posts: 110


View Profile
« Reply #7 on: February 16, 2010, 07:26:33 AM »

The SDL.dll is required, and I think the terminal.png file is required (I fell foul of that one when I first started) if you don't specify another font explicitly.

I do know what all the DLLs and the terminal.png need to go in the "root" of the project, otherwise Python can't find them. I haven't developed in the Python version of LibTCOD for a bit, so I might be wrong here.
Logged
george
Master
****
Posts: 216


View Profile
« Reply #8 on: February 16, 2010, 08:06:49 AM »

Yeah, you need the terminal.png font in there with your src (or you need to specify your font explictly, see the docs/libtcod font readme). Otherwise it looks like you have all the DLLs with your src, so that looks OK. Maybe try moving all the src files and dlls to the top level dir.
Logged
Boco
Apprentice
*
Posts: 7


View Profile
« Reply #9 on: February 16, 2010, 08:26:22 AM »

Yeah, you need the terminal.png font in there with your src (or you need to specify your font explictly, see the docs/libtcod font readme). Otherwise it looks like you have all the DLLs with your src, so that looks OK. Maybe try moving all the src files and dlls to the top level dir.
I added the terminal.png file to the same place as the DLL files. They are in the project directory as well as the project/src directory. Same error. Same thing just running it from a prompt

Code:
C:\Users\Boco\Documents\NetBeansProjects\pyrl\src>python main.py
Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import libtcodpy as libtcod
  File "C:\Users\Boco\Documents\NetBeansProjects\pyrl\src\libtcodpy.py", line 41, in <module>
    _lib = ctypes.cdll['./libtcod-mingw.dll']
  File "C:\Python26\lib\ctypes\__init__.py", line 428, in __getitem__
    return getattr(self, name)
  File "C:\Python26\lib\ctypes\__init__.py", line 423, in __getattr__
    dll = self._dlltype(name)
  File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

Directory tree:
Code:
Directory of C:\Users\Boco\Documents\NetBeansProjects\pyr

02/16/2010  02:17 AM    <DIR>          .
02/16/2010  02:17 AM    <DIR>          ..
02/15/2010  08:40 PM           262,772 libtcod-gui-mingw-debug.dll
02/15/2010  08:41 PM            83,750 libtcod-gui-mingw.dll
02/15/2010  08:40 PM         1,442,540 libtcod-mingw-debug.dll
02/15/2010  08:41 PM           332,430 libtcod-mingw.dll
02/15/2010  08:57 PM    <DIR>          nbproject
02/15/2010  08:40 PM           135,168 SDL.dll
02/16/2010  02:19 AM    <DIR>          src
02/16/2010  02:12 AM             3,150 terminal.png
               6 File(s)      2,259,810 bytes
               5 Dir(s)  260,353,175,552 bytes free


 Directory of C:\Users\Boco\Documents\NetBeansProjects\pyrl\src

02/16/2010  02:19 AM    <DIR>          .
02/16/2010  02:19 AM    <DIR>          ..
02/16/2010  02:16 AM    <DIR>          fonts
02/15/2010  08:40 PM           262,772 libtcod-gui-mingw-debug.dll
02/15/2010  08:41 PM            83,750 libtcod-gui-mingw.dll
02/15/2010  08:40 PM         1,442,540 libtcod-mingw-debug.dll
02/15/2010  08:41 PM           332,430 libtcod-mingw.dll
02/15/2010  09:01 PM            47,247 libtcodpy.py
02/15/2010  09:02 PM            80,704 libtcodpy.pyc
02/16/2010  02:13 AM               785 main.py
02/15/2010  08:40 PM           135,168 SDL.dll
02/16/2010  02:11 AM             3,150 terminal.png
               9 File(s)      2,388,546 bytes
               3 Dir(s)  260,353,110,016 bytes free

I was hoping this would fix it Sad
Logged
george
Master
****
Posts: 216


View Profile
« Reply #10 on: February 16, 2010, 08:30:47 AM »

Ahhh....could it be that the DLL was compiled for 32 bit? I'm out of my element on that question, maybe jice or Mingos can help.


another question...is your Python 64 or 32 bit?


edit: OK, sorry I see it was in the OP: "Python v2.6.4 amd64". I think that's the issue. (second edit: to clarify, I think the 64 bit Python is calling a 32 bit process, and I don't think -- not sure, but don't think -- that will work).
« Last Edit: February 16, 2010, 08:56:01 AM by george » Logged
jice
Administrator
Master
*****
Posts: 1455


View Profile WWW
« Reply #11 on: February 16, 2010, 09:41:28 AM »

Do the libtcod python samples work on your system ? If they don't, no need to look further... Dunno how python's ctypes behave with mixed 32bits/64bits installation...
Logged
Boco
Apprentice
*
Posts: 7


View Profile
« Reply #12 on: February 16, 2010, 03:30:01 PM »

Do the libtcod python samples work on your system ? If they don't, no need to look further... Dunno how python's ctypes behave with mixed 32bits/64bits installation...
Can't say since I'm at work right now. I'll take a look when I get home. It probably wouldn't be such a good idea to compile a 64bit version. Maybe I'll just have to use a 32bit version of python rather than 64bit.
Logged
Boco
Apprentice
*
Posts: 7


View Profile
« Reply #13 on: February 17, 2010, 12:08:19 AM »

Do the libtcod python samples work on your system ? If they don't, no need to look further... Dunno how python's ctypes behave with mixed 32bits/64bits installation...
Can't say since I'm at work right now. I'll take a look when I get home. It probably wouldn't be such a good idea to compile a 64bit version. Maybe I'll just have to use a 32bit version of python rather than 64bit.
Well, that worked. Replaced the 64-bit python with the 32-bit. I hope I don't miss out on anything from the change. Thanks for your help, I hadn't considered the possibility.
edit: Apparently I missed the Modify button and pressed Quote. Oops...
Logged
Pages: [1]
  Print  
 
Jump to: