RoonCommandLine Version 2.0.5 Release 1

@DaveN , let’s keep making progress! The python3 test command I provided you needs to be run in the same directory as the script it is being given on the command line or provide a path to the script. Try again for me with the full path to the script as follows:

python3 /usr/local/Roon/api/list_tags.py -t __all__

This should at least get beyond the previous error of not finding the roonapi Python module. Then we can take on the next problem it encounters. Btw, do you actually have any tags defined in your Roon library? That is, do we expect roon -l tags to return a list of tags?

Good going getting the roonapi module installed and welcome to the unglamorous slog of debugging :slight_smile:

That returns the following, but takes around three seconds to do so, so it’s clearly doing something:

djn@trinity RoonCommandLine % python3 /usr/local/Roon/api/list_tags.py -t __all__
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_tags.py", line 65, in <module>
    tags = roonapi.list_media(output_id, ["Library", "Tags", searchterm])
  File "/Users/djn/.pyenv/versions/3.10.3/lib/python3.10/site-packages/roonapi/roonapi.py", line 455, in list_media
    total_count = self.browse_browse(opts)["list"]["count"]
TypeError: 'NoneType' object is not subscriptable

Yes, I have 75 tags.

I’m happy slogging along if you are :slight_smile:

@DaveN , another thing to check is the PYTHONUSERBASE setting in /usr/local/Roon/etc/pyroonconf. This tells Python the base path to the user site-packages where the roonapi module is installed. It is possible this base path is incorrect as it was set during the initial RoonCommandLine installation and may have been incorrectly preserved over upgrades. I just thought of this and I may need to modify the way upgrades are done to recalculate this environment variable. Or handle it differently.

The PYTHONUSERBASE setting should match up with the leading components in the Location: returned by python3 -m pip show roonapi

Send me your pyroonconf and I will check it for possible misconfiguration.

export PYTHONUSERBASE=/Library/Frameworks/Python.framework/Versions/3.10
ROONAPIPATCHED=true
ROON_ZONE="Kef LSX"
LOCAL=true

So there is a mismatch. What do I need to change?

I don’t know if this helps, but I just tried changing the path in pyroonconf and ran ‘roon -l tags’. Both paths generate the same error:

djn@trinity RoonCommandLine % roon -l tags
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_tags.py", line 65, in <module>
    tags = roonapi.list_media(output_id, ["Library", "Tags", searchterm])
  File "/Users/djn/.pyenv/versions/3.10.3/lib/python3.10/site-packages/roonapi/roonapi.py", line 455, in list_media
    total_count = self.browse_browse(opts)["list"]["count"]
TypeError: 'NoneType' object is not subscriptable
djn@trinity RoonCommandLine % roon -l tags
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_tags.py", line 65, in <module>
    tags = roonapi.list_media(output_id, ["Library", "Tags", searchterm])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/roonapi/roonapi.py", line 455, in list_media
    total_count = self.browse_browse(opts)["list"]["count"]
TypeError: 'NoneType' object is not subscriptable

PYTHONUSERBASE may not be the problem, I’m just worried I may be handling it wrong across upgrades. I’ll continue to think about it.

Can you run the following command for me and provide me with the output:

python3 -c 'import site; print(site.getsitepackages())' | tr -d '[],'

I know, it’s gnarly. This should return a list of paths to site and/or dist package directories. It may help me understand how to set the Python userbase in environments like yours.

The error you are seeing is a common Python exception and it will eventually need to be addressed in the Python Roon API code. We need to find a way to work around it for now. I am going to perform additional tests. Hang in there!

djn@trinity RoonCommandLine % python3 -c 'import site; print(site.getsitepackages())' | tr -d '[],'
'/Users/djn/.pyenv/versions/3.10.3/lib/python3.10/site-packages'

Happily hanging, as we speak :slight_smile:

Thanks, and your pyroonconf has the line:

export PYTHONUSERBASE=/Users/djn/.pyenv/versions/3.10.3

Correct?

Do you want to try reinstalling RoonCommandLine again? I am not coming up with any bright ideas. A clean reinstall may resolve some issues. It would require a little scrubbing first.

To perform a clean reinstall you will first need to remove the roonapi module and after uninstalling RoonCommandLine make sure no config files will be carried forward:

python3 -m pip uninstall roonapi

Then uninstall RoonCommandLine:

cd /path/to/RoonCommandLine
./Uninstall

Verify /usr/local/Roon is no longer present. If it is, remove it:

sudo rm -rf /usr/local/Roon

Remove any RoonCommandLine config files saved for upgrade:

sudo rm -f /tmp/_roon_api_ini_.save
sudo rm -f /tmp/_pyroonconf_.save

Finally, install RoonCommandLine. I forget, are you on a Mac? If so:

cd /path/to/RoonCommandLine
./clean
git pull
./Install

If on Linux then install using the Debian or RPM package.

I hope this is not too overwhelming or tedious or frustrating. And, it may not resolve the issue! It just cleans things up a bit.

No, it’s as follows:

export PYTHONUSERBASE=/Library/Frameworks/Python.framework/Versions/3.10

But even if I change it to 'export PYTHONUSERBASE=/Library/Frameworks/Python.framework/Versions/3.10
’ it doesn’t make any difference.

Should I still try the clean reinstall?

Before reinstalling let me do a little more digging. Can you tell me how you installed Python and if you have multiple Python installations? Do you have Python installed in /Library/Frameworks/… or elsewhere as well as Python installed locally as user ‘djn’? What does type -p python3 return? What about sudo type -p python3 ?

I want to try and replicate your environment on a spare Mac Mini. It may be that doing a clean reinstall would help, either resolving issues or more likely help by giving us a cleaner environment to examine. But, for now, let me dig.

OK, so I went through the steps as listed, but it didn’t make any difference. Two things to note: first pyroonconf still says the following:

export PYTHONUSERBASE=/Library/Frameworks/Python.framework/Versions/3.10

Also, when I now run python3 -m pip show roonapi I get the following:

djn@trinity RoonCommandLine % python3 -m pip show roonapi
WARNING: Package(s) not found: roonapi

Despite that, numerous commands do work. For example roon -l albums does return a list of my albums, and I can playpause, increase and decrease volume, and so on.

Just seen your latest post …

djn@trinity RoonCommandLine % type -p python3
python3 is /Users/djn/.pyenv/shims/python3
djn@trinity RoonCommandLine % sudo type -p python3
Password:
/Users/djn/.pyenv/shims/python3

I previously had Python installed as a consequence of running Annaconda, I think. I deleted this earlier today and installed using pyenv.

It seems so …

/Library/Frameworks/Python.framework/Versions/3.10/Python 

Not at all, I’m happy to carry on until we’ve nailed it.

FYI:

EDIT: If it would be easier, I’d be happy to uninstall and reinstall Python. I know a bit about Macs, and a bit about programming - probably just enough to have thoroughly messed things up :wink:

Just read back through the thread and realised that if roonapi isn’t installed, as per python3 -m pip show roonapi, then installing RoonCommandLine must be failing to install it. I’ve just manually installed it again using python3 -m pip install roonapi but it didn’t make any difference – still getting the same error.

Man, you really have given me a lot to ponder! How is it possible that roon -l albums works but roon -l tags fails in this way? I guess we should count ourselves lucky to have interesting problems.

What does pyenv versions say about your installed Python versions managed by pyenv? What happens when you revert to the system installed Python by running pyenv global system followed by either roon -l albums or roon -l tags ?

If using the system Python differs from your local pyenv installed version, how does it behave invoking the Python scripts directly:

python3 /usr/local/Roon/api/list_tags.py -t __all__

and

[EDIT]

python3 /usr/local/Roon/api/list_albums.py -a __all__

with both of your Python installations selected using pyenv? That is, run those commands using the system Python then again using the Python installed locally with pyenv. I think you can do this using pyenv global system for one set of invocations then pyenv global 3.10.3 for another set of invocations. Is there any difference?

1 Like

Just in case there was some miraculous change, I ran both again: roon -l albums definitely works, roon -l tags definitely does not.

djn@trinity lastcollage-cli % pyenv versions
  system
* 3.10.3 (set by /Users/djn/.pyenv/version)
djn@trinity lastcollage-cli % pyenv global system 
djn@trinity lastcollage-cli % roon -l tags       
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_tags.py", line 65, in <module>
    tags = roonapi.list_media(output_id, ["Library", "Tags", searchterm])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/roonapi/roonapi.py", line 455, in list_media
    total_count = self.browse_browse(opts)["list"]["count"]
TypeError: 'NoneType' object is not subscriptable

roon -l albums still works as expected.

djn@trinity lastcollage-cli % pyenv global system
djn@trinity lastcollage-cli % python3 /usr/local/Roon/api/list_tags.py -t __all__
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_tags.py", line 65, in <module>
    tags = roonapi.list_media(output_id, ["Library", "Tags", searchterm])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/roonapi/roonapi.py", line 455, in list_media
    total_count = self.browse_browse(opts)["list"]["count"]
TypeError: 'NoneType' object is not subscriptable
djn@trinity lastcollage-cli % pyenv global 3.10.3
djn@trinity lastcollage-cli % python3 /usr/local/Roon/api/list_tags.py -t __all__
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_tags.py", line 65, in <module>
    tags = roonapi.list_media(output_id, ["Library", "Tags", searchterm])
  File "/Users/djn/.pyenv/versions/3.10.3/lib/python3.10/site-packages/roonapi/roonapi.py", line 455, in list_media
    total_count = self.browse_browse(opts)["list"]["count"]
TypeError: 'NoneType' object is not subscriptable

No difference for tags. No difference for albums.

Yep, definitely better than boring ones :slight_smile:

I installed pyenv and installed Python 3.10.3 using pyenv to try and replicate your Python execution environment.I had to install the roonapi module in the newly installed Python 3.10.2 as expected and as you did. And I had to do all the pyenv setup stuff in my .bashrc and .bash_profile but when I got it all setup I still am unable to replicate your errors. I can list albums, tags, genres, etc.

Did you verify that your pyenv setup is correct? That is, did you run python3 --version after changing your Python version with pyenv?

Looks like it’s not pyenv or Python 3.10.3 so what is it? Back to the think tank.

djn@trinity 3.10.3 % python3 --version

Python 3.10.3

It might help if you told me what needs to be in these files so I can check mine, but I’m also using zsh. Here’s what I have:

.bashrc
eval “$(pyenv init -)”

.bash_profile
eval “$(pyenv init --path)”

.zshrc
eval “$(pyenv init --path)”

This is a kind of confusing part of pyenv as the instructions on their own github site are not exactly correct. But, that is partly because the various shells use so many different ways to initialize their environment. The pyenv README has a lengthy section on setting up shell environments. With Bash on my Mac I did the following:

In my .bash_profile I added:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"

and in my .bashrc I added:

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

The pyenv Github README has this for zsh on a Mac:

If Pyenv is installed with Homebrew:

echo 'eval "$(pyenv init --path)"' >> ~/.zprofile

echo 'eval "$(pyenv init -)"' >> ~/.zshrc

If Pyenv is installed with a Git checkout:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zprofile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zprofile
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile

echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Make sure that your terminal app runs the shell as a login shell.

To test if the pyenv shell environment is setup correctly, after editing the .zshrc and .zprofile or whatever shell startup files you have, logout then login and check python3 --version for a couple of different pyenv Python installs. That is, do something like:

pyenv global system
python3 --version
pyenv global 3.10.3
python3 --version

The two python3 --version commands should show the two different Python versions managed by pyenv.

Sorry, didn’t see your last message. In the meanwhile I thought I’d try and simplify things by ditching Pyenv, so I’m now back to a standard install of Python.

djn@trinity / % python3 --version
Python 3.10.4

I uninstalled and reinstalled RoonCommandLine and the Roon API is installed correctly:

djn@trinity / % python3 -m pip show roonapi
Name: roonapi
Version: 0.1.1
Summary: Provides a python interface to interact with Roon
Home-page: https://github.com/pavoni/pyroon
Author: Marcel van der Veldt
Author-email: 
License: Apache-2.0
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: ifaddr, requests, six, websocket_client

roon -l albums still works, roon -l tags does not.

I’m turning in now–it’s almost 2.30am here–but if you think of anything else you’d like me to try tomorrow, please let me know.

EDIT: roon -l genres also fails, and roon -l playlists just shows ‘An Introduction to Qobuz!’ - which is one of 17 playlists. Everything else seems to work as expected, but I haven’t tested everything so there may be additional issues I haven’t come across yet.