v0.3.16 (SVN 4046) Python error with OSX

Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report on GitHub. For problems building from source, post in Compile.

Moderator: Oberlus

Post Reply
Message
Author
Quercus
Space Krill
Posts: 4
Joined: Tue Jul 26, 2011 6:14 pm

v0.3.16 (SVN 4046) Python error with OSX

#1 Post by Quercus »

First off, great work and a fun game. During multiplayer game between a human and one AI, I observed AI not exploring, colonizing, etc. AI doesn't seem to work in single player either, but I can't run as observer to verify it's nonfunctional during the game.

The AI log from the multiplayer game showed a namespace error after running the PythonAI file:
2011-08-02 21:36:04,318 DEBUG AI : Initializing C++ interfaces for Python
2011-08-02 21:36:06,026 ERROR AI : Unable to set up main namespace in Python.

I'm running OSX 10.6.8 on a 2.8GHz iMac. I have python 2.6.1 installed, but the game defaults to using Python version 2.5.5 that is included with the OSX FreeOrion v0.3.16 binary.

The python modules are present in the expected directories (i.e. inside /Applications/FreeOrion.app/Contents/Frameworks/Python.framework/Versions/Current) on my iMac.

The AI python script files are present inside /Applications/FreeOrion.app/Contents/Resources/default/AI directory, too.

Couldn't find any similar Python problem in the forums, just the old "capitolID" vs "HomeworldID" bug inside the ExplorationAI.py file, but that looks fixed with v0.3.16.
Attachments
AI_1.log.zip
Here is the zipped log file for AI_1.log
(22.9 KiB) Downloaded 49 times

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: v0.3.16 (SVN 4046) Python error with OSX

#2 Post by Geoff the Medio »

Hmm... odd. I don't recall seeing this problem before either. Unfortunately, I neglected to print the Python error text for that particular instruction, so debugging this will be quite difficult. The problem is fairly fundamental though, as the __main__ namespace is always supposed to exist.

Could you try deleting all the Python 2.5.5 stuff from the FreeOrion directory? Maybe that will force it to use 2.6 and it will magically start working?

Quercus
Space Krill
Posts: 4
Joined: Tue Jul 26, 2011 6:14 pm

Re: v0.3.16 (SVN 4046) Python error with OSX

#3 Post by Quercus »

Instead of deleting the 2.5 folder, I think I'll try editing the symbolic links that point it to the 2.5 directory and instead point to the directory structure where I have 2.6.

Specifically, in the /Applications/FreeOrion.app/Contents/Frameworks/Python.framework there are three symbolic links:
Headers -> Versions/Current/Headers
Python -> Versions/Current/Python
Resources -> Versions/Current/Resources

I figured I could change these 3 sym links and point them to:
/System/Library/Frameworks/Python.framework/Versions/Current/Headers
/System/Library/Frameworks/Python.framework/Versions/Current/Resources
/System/Library/Frameworks/Python.framework/Versions/Current/Python

Will let you know how it goes.

zalasur
Krill Swarm
Posts: 11
Joined: Fri Aug 05, 2011 1:00 am

Re: v0.3.16 (SVN 4046) Python error with OSX

#4 Post by zalasur »

Quercus wrote:Instead of deleting the 2.5 folder, I think I'll try editing the symbolic links that point it to the 2.5 directory and instead point to the directory structure where I have 2.6.

Specifically, in the /Applications/FreeOrion.app/Contents/Frameworks/Python.framework there are three symbolic links:
Headers -> Versions/Current/Headers
Python -> Versions/Current/Python
Resources -> Versions/Current/Resources

I figured I could change these 3 sym links and point them to:
/System/Library/Frameworks/Python.framework/Versions/Current/Headers
/System/Library/Frameworks/Python.framework/Versions/Current/Resources
/System/Library/Frameworks/Python.framework/Versions/Current/Python

Will let you know how it goes.
What I just found out is you can do this: First, remove the following symlink:

/Applications/FreeOrion.app/Contents/Frameworks/Python.framework/Versions/Current

and point it instead to this link:

/System/Library/Frameworks/Python.framework/Versions/Current

It does essentially the same thing you were doing, but with less typing. :)

Also, it did in fact take care of the python error, and on top of that, the AI seems to be somewhat productive now as opposed to just sitting there. :lol:

Quercus
Space Krill
Posts: 4
Joined: Tue Jul 26, 2011 6:14 pm

Re: v0.3.16 (SVN 4046) Python error with OSX

#5 Post by Quercus »

In the end I edited the 3 sym links and deleted the existing Python 2.5.5 files (per Geoff's recommendation) that ship with the binary. Still had an error in the AI log file, though, because it couldn't find the modules in the 2.6 directories.

Had to create a link to /System/Library/Frameworks/Python.framework/Versions/Current

That did the trick, and the AI was off and running, exploring, etc.

night
Space Kraken
Posts: 102
Joined: Sun Jun 12, 2011 1:21 pm

Re: v0.3.16 (SVN 4046) Python error with OSX

#6 Post by night »

I updated* the built-in Python framework to 2.7.1 in my latest build/SDK over here. Could you please test it and tell me if it's working out of the box?

*just copied the files from my /System/Library/Frameworks/Python.framework

Quercus
Space Krill
Posts: 4
Joined: Tue Jul 26, 2011 6:14 pm

Re: v0.3.16 (SVN 4046) Python error with OSX

#7 Post by Quercus »

Got the AI scripts running on my macbook pro, but I found there were errors in the AI log when running FO on my iMac even though both computers were running OSX 10.6.8 and had Python 2.6 installed. The Python 2.6 installations were very different.

Inexplicably, the Python 2.6 install on the iMac had only one file in the /System/Library/Frameworks/Python.framework/Versions/Current/include/python2.6 directory. There were 88 files in that same directory on the laptop.

Also, there was no Header sym link inside /System/Library/Frameworks/Python.framework/Versions/Current. It's supposed to be there and pointing at /include/python2.6

I copied the include files from the laptop to the iMac and created the missing symbolic links. Now the AI on the iMac seems to work properly- no ERROR messages in the AI log files.

night
Space Kraken
Posts: 102
Joined: Sun Jun 12, 2011 1:21 pm

Re: v0.3.16 (SVN 4046) Python error with OSX

#8 Post by night »

Have you tried the new build I posted? It should run without any changes, since Python 2.7.1 is included in the FreeOrion app bundle now.

Post Reply