Thanks f00b4r.
OK, forcing Plexconnect.py to run specifically on python 2.7 cleared up the preplay screen error described here. Running Plexconnect normally on my system must have been calling the default 2.6 version of python.
Not sure why Plexconnect is doing that. As far as I can tell I have changed PATH symlink at usr/bin/python to point to python 2.7 to make it the default version and it does appear as such when in bash and I type python.
Deleted
In this instance I forced it through terminal
sudo python2.7 /Plexconnect.py
But this is awkward as I can’t use the AppleScript, as is, and I would rather just have python 2.7 acting as the default for everything.
Perhaps you could replace the python path at the top of the Plexconnect.py with a direct path to python 2.7? But I would wait until a developer OKs that sort of thing.
OK, I changed the python path to
user/local/bin/python
and the error is gone. Obviously I have only installed python 2.7 for the main user and not for the computer as a whole. I’ll have to work on that.
OK, I changed the python path to
user/local/bin/python
and the error is gone. Obviously I have only installed python 2.7 for the main user and not for the computer as a whole. I'll have to work on that.
Good news, would you like to knock together some idiots guide step by step instructions and i will put them up on the wiki for anyone else? :)
Sure, if you need someone to tell people how to mess up a Python 2.7 install :mellow: . Seriously, once I find out how to do it properly I will put something together that explains the pitfalls and solution.
This is how I updated Python for OS X and got the new Python version working with PlexConnect.
- In the Terminal, enter the following command to get the version number of Python installed in /usr/bin, the directory where the default OS X install of Python is located:
python --version
My version of Python was 2.6.1 on OS X Server 10.6.8. With this version, I was seeing the graphical metadata glitches. So I need a newer version of Python.
- Download the latest version of Python from here: Python 2.7.5.
- Mount the DMG and run the installer which will install Python 2.7.5 (or whatever version you downloaded) into /usr/local/bin (this is the directory for user-installed binaries).
- Open the Python 2.7 folder in /Applications and double-click the “Update Shell Profile.command”. This will update your PATH (bash profile) so that the Terminal will use the newer version of Python (/usr/local/bin/python) rather than the older one (/usr/bin/python).
- In the Terminal, enter:
python --version
Your Python version should now be 2.7.5.
- Restart PlexConnect. Then launch PlexConnect on your Apple TV to see if the graphical glitches are gone.
Note: For those on OS X 10.6.8 that use a launchctl plist to run PlexConnect, you will have to change the shebang lines in the PlexConnect files from #!/usr/bin/env python to #!/usr/local/bin/python.
fOOb4r/Baa/roidy,
Any chance that a line could be added to Settings.cfg that will allow us to use Python installed in /usr/local/bin so we don’t have to edit the PlexConnect.py script every time we update PlexConnect?
Nice step by step elstreif.
That is what I did. I think there is a way to turn the new python version that is installed in /usr/local/bin/python to be the default version for calls to /usr/bin/python by updating the PATH. I have not, however, been successful doing so yet. Any experts out there who know?
The problem with that is adding code that is platform specific, it would be better to sort out the default python on 10.6 properly.
Well, you can symlink the old version to the new version but that really, really, really isn't recommended or a good idea. So far, it seems as if you have to specify the version or path in the script, but that breaks compatibility with other platforms and systems.
The problem with that is adding code that is platform specific, it would be better to sort out the default python on 10.6 properly.
I tried editing PlexConnect.py with #!/usr/bin/env python as mentioned here and in this StackOverflow thread, but PlexConnect doesn't seem to launch properly when I do that. It sounds as if it should work because others use #!/usr/bin/env in scripts.
And apparently, using #!/usr/bin/env python will work without modification on Linux, Windows, and other Unixes.
I found this on stackoverflow but couldn't get it to work (I did adapt the python versions to my needs). Does it need to have the versions all in usr/bin/?
Quote:
Apple has provided two very simple ways to change the default python on OS X 10.6 Snow Leopard and 10.7 Lion. It's all detailed in the Apple man page for python(1):
$ man python
$ which python
/usr/bin/python
$ python -V
Python 2.7.1
#
# temporarily change version
#
$ export VERSIONER_PYTHON_VERSION=2.6
$ python -V
Python 2.6.6
$ unset VERSIONER_PYTHON_VERSION
$ python -V
Python 2.7.1
#
# persistently change version
#
$ defaults write com.apple.versioner.python Version 2.6
$ python -V
Python 2.6.6
That VERSIONER setting is for Apple-built python installations only.
See if you can get it to work. Edit the first line of your PlexConnect.py file so it reads #!/usr/bin/env python instead of #!/usr/bin/python
Does it work for you? By using “#!/usr/bin/env python”, the script is supposed to check the PATH for the preferred version of Python if you have multiple versions installed. If you just have the OS default version of Python installed, then it will use that one. #!/usr/bin/env python is also supposed to work on Linux and Windows. So there is no need to specify the direct path (e.g., /usr/bin/python) to Python.
Thing is, it’s not working for me. If I launch the script manually it appears to work, but if I use the launchctl plist (from another thread) which launches the script at startup, it launches the older version of Python. I don’t understand why it does this.
I found this on stackoverflow but couldn’t get it to work (I did adapt the python versions to my needs). Does it need to have the versions all in usr/bin/?
Quote:
Apple has provided two very simple ways to change the default python on OS X 10.6 Snow Leopard and 10.7 Lion. It’s all detailed in the Apple man page for python(1):
$ man python
$ which python
/usr/bin/python
$ python -V
Python 2.7.1
#
# temporarily change version
#
$ export VERSIONER_PYTHON_VERSION=2.6
$ python -V
Python 2.6.6
$ unset VERSIONER_PYTHON_VERSION
$ python -V
Python 2.7.1
#
# persistently change version
#
$ defaults write com.apple.versioner.python Version 2.6
$ python -V
Python 2.6.6
I thought f00b4r's point was that they would prefer to leave it as "usr/bin/python" and that it is up to us on OS X 10.6 to figure out our default python issue.
I will try your "env" approach, though, when I am back at the home computer, probably won't be until tomorrow.
Found this: http://docs.python.org/3/tutorial/interpreter.html#executable-python-scripts
2.2.2. Executable Python Scripts
On BSD’ish Unix systems, Python scripts can be made directly executable, like shell scripts, by putting the line
#! /usr/bin/env python3.3(assuming that the interpreter is on the user’s PATH) at the beginning of the script and giving the file an executable mode. The #! must be the first two characters of the file. On some platforms, this first line must end with a Unix-style line ending (' '), not a Windows (' ') line ending. Note that the hash, or pound, character, '#', is used to start a comment in Python.
The script can be given an executable mode, or permission, using the chmod command:
$ chmod +x myscript.pyOn Windows systems, there is no notion of an “executable mode”. The Python installer automatically associates .py files with python.exeso that a double-click on a Python file will run it as a script. The extension can also be .pyw, in that case, the console window that normally appears is suppressed.
Unfortunately, you can't update the system default python. All you can do is point to a different version in a different location. PlexConnect.py uses hard paths, but from what I've read, the recommended method is to use the env utility in your scripts. But I'm not a python developer, so maybe the PlexConnects devs can chime in on this with their thoughts about using env.
I thought f00b4r's point was that they would prefer to leave it as "usr/bin/python" and that it is up to us on OS X 10.6 to figure out our default python issue.
This is from a python.org mail thread. Maybe it explains why it doesn't work with launchctl.
One of the main dis-advantages to using '/usr/bin/env python' is that
you have to either A. make sure the environment is initialized, or B.
initialize the environment manually before executing the script. If
you, for example, want to use a python script at boot time, before the
environment is initialized, i strongly recommend using an absolute path.
http://mail.python.org/pipermail/tutor/2007-June/054936.html
I thought f00b4r's point was that they would prefer to leave it as "usr/bin/python" and that it is up to us on OS X 10.6 to figure out our default python issue.
I will try your "env" approach, though, when I am back at the home computer, probably won't be until tomorrow.
Yeah that was my point.
Maybe Baa or Roidy can chime in on this but I think that trying to make the actual changes on the actual 10.6 installation would be best, especially if it is not trivial and 10.9 is out soon.
Out of interest is there a reason you are still running 10.6, is it because your hardware is not compatible with later versions?
Nice find. That's probably it. For now, I'm going to stick with manually adding the absolute path to the newer Python until someone, hopefully, finds an effective way to do this.
This is from a python.org mail thread. Maybe it explains why it doesn't work with launchctl.
One of the main dis-advantages to using '/usr/bin/env python' is that
you have to either A. make sure the environment is initialized, or B.
initialize the environment manually before executing the script. If
you, for example, want to use a python script at boot time, before the
environment is initialized, i strongly recommend using an absolute path.http://mail.python.org/pipermail/tutor/2007-June/054936.html