mdbraber / radiobar

macOS menubar app to listen to streaming radio
MIT License
56 stars 8 forks source link

'NoneType' object is not subscriptable ? #1

Open steveharman opened 5 years ago

steveharman commented 5 years ago

macOS 10.14. Python 3.7.2 (also tried with Python 2.7.10)

I get 'NoneType' object is not subscriptable ? from python3 setup.py py2app - can anyone help please? setup seems to be complaining about py2app being required, but afaict I already have it?

➜  pip3 install py2app
Requirement already satisfied: py2app in /usr/local/lib/python3.7/site-packages (0.18)
Requirement already satisfied: macholib>=1.11 in /usr/local/lib/python3.7/site-packages (from py2app) (1.11)
Requirement already satisfied: altgraph>=0.16 in /usr/local/lib/python3.7/site-packages (from py2app) (0.16.1)
Requirement already satisfied: modulegraph>=0.17 in /usr/local/lib/python3.7/site-packages (from py2app) (0.17)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from modulegraph>=0.17->py2app) (40.8.0)

and:

➜  ~ pip install py2app
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: py2app in /Library/Python/2.7/site-packages (0.18)
Requirement already satisfied: altgraph>=0.16 in /Library/Python/2.7/site-packages (from py2app) (0.16.1)
Requirement already satisfied: modulegraph>=0.17 in /Library/Python/2.7/site-packages (from py2app) (0.17)
Requirement already satisfied: macholib>=1.11 in /Library/Python/2.7/site-packages (from py2app) (1.11)
Requirement already satisfied: setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from modulegraph>=0.17->py2app) (18.5)

Here's setup's full complaint:

Thanks,

➜  radiobar git:(master) python3 setup.py py2app
running py2app
creating /Users/steveharman/radiobar/build
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64/python3.7-standalone
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64/python3.7-standalone/app
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/collect
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/temp
creating /Users/steveharman/radiobar/dist
creating build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/Frameworks
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    setup_requires=['py2app'],
  File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.18-py3.7.egg/py2app/build_app.py", line 838, in run
    self._run()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.18-py3.7.egg/py2app/build_app.py", line 1053, in _run
    self.run_normal()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.18-py3.7.egg/py2app/build_app.py", line 1146, in run_normal
    mf = self.get_modulefinder()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.18-py3.7.egg/py2app/build_app.py", line 997, in get_modulefinder
    debug=debug,
  File "/Users/steveharman/radiobar/.eggs/modulegraph-0.17-py3.7.egg/modulegraph/find_modules.py", line 338, in find_modules
    find_needed_modules(mf, scripts, includes, packages)
  File "/Users/steveharman/radiobar/.eggs/modulegraph-0.17-py3.7.egg/modulegraph/find_modules.py", line 256, in find_needed_modules
    path = m.packagepath[0]
TypeError: 'NoneType' object is not subscriptable
mdbraber commented 5 years ago

This seems like an error with py2app. I'm not at my computer right now, but I'll investigate later. It could also help to report this error to the py2app developers.

steveharman commented 5 years ago

Thanks @mdbraber - I just updated my ticket with a little more detail.

mdbraber commented 5 years ago

@steveharman are you possibly using PYTHONPATH to specific modules? If so you should use the --use-pythonpath option like described here: https://py2app.readthedocs.io/en/latest/options.html

mdbraber commented 5 years ago

@steveharman here's an approach to debug Python issues:

This is a general guide to debugging setup.py issues, or actually python issues in general (copied from: https://stackoverflow.com/questions/16131500/py2app-error-in-find-needed-modules-typeerror-nonetype-object-has-no-attribu)

  1. Run it again in interactive mode, i.e. python3 -i setup.py py2app. Once setup.py exits you will find yourself in a python prompt.
  2. Run from pdb import pm; pm(). You should now find yourself at a debug prompt.
  3. Type up and hit enter - you are now a frame higher in the stack - you can type list to see where in the source code the current frame is positioned, and args to see the arguments passed to the current frame (usually a function or method). You can also run python commands to inspect the current state, and run pp var to pretty-print that variable.
  4. Once you have repeated the above step a few times you will find where the error is encountered - in the case I encountered where it was a README file I found a variable called lineno which gave the line of my README file which caused the error. If your problem is a module import, it'll probably be something different, but my instinct is that you'll find yourself looping over the packages argument seen in your stack trace, and the current list item will be the key to your problem.
steveharman commented 5 years ago

I'm really sorry @mdbraber I simply don't have time to go into resolving this right now. I've never knowingly touched Python before, I just wanted a menubar radio app for my Mac. ;-)

mdbraber commented 5 years ago

@steveharman unfortunately as I can't reproduce the issue it might be due to your local environment. I'll try to investigate a bit more and see if I can reproduce. One question: did you install python3 using brew?

steveharman commented 5 years ago

perfectly understood @mdbraber

and yes to python3 via brew

happy to help debug if there are some quickfire "do this, try this, let me know" steps.

steveharman commented 5 years ago

Hi @mdbraber

I tried the steps you mentioned, here's my output:


running py2app
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64/python3.7-standalone/app
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/collect
creating /Users/steveharman/radiobar/build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/temp
creating build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.14-x86_64/python3.7-standalone/app/Frameworks
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    setup_requires=['py2app'],
  File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.7/site-packages/py2app/build_app.py", line 838, in run
    self._run()
  File "/usr/local/lib/python3.7/site-packages/py2app/build_app.py", line 1053, in _run
    self.run_normal()
  File "/usr/local/lib/python3.7/site-packages/py2app/build_app.py", line 1146, in run_normal
    mf = self.get_modulefinder()
  File "/usr/local/lib/python3.7/site-packages/py2app/build_app.py", line 997, in get_modulefinder
    debug=debug,
  File "/usr/local/lib/python3.7/site-packages/modulegraph/find_modules.py", line 338, in find_modules
    find_needed_modules(mf, scripts, includes, packages)
  File "/usr/local/lib/python3.7/site-packages/modulegraph/find_modules.py", line 256, in find_needed_modules
    path = m.packagepath[0]
TypeError: 'NoneType' object is not subscriptable
>>> from pdb import pm; pm()
> /usr/local/lib/python3.7/site-packages/modulegraph/find_modules.py(256)find_needed_modules()
-> path = m.packagepath[0]
(Pdb) up
> /usr/local/lib/python3.7/site-packages/modulegraph/find_modules.py(338)find_modules()
-> find_needed_modules(mf, scripts, includes, packages)
(Pdb) list
333             path=path,
334             excludes=(excludes - includes),
335             implies=get_implies(),
336             debug=debug,
337         )
338  ->     find_needed_modules(mf, scripts, includes, packages)
339         return mf
[EOF]
(Pdb)```

Afraid I have no knowledge of "PYTHONPATH".

Steve
wasbeer commented 5 years ago

The following steps resulted in a working app for me:

  1. Make sure you install python via pyenv with the following flag (to get the dylib): env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.7.4

  2. Delete the setup.py and make a new one py2applet --make-setup radiobar.py

  3. Build the app using py2app python -i setup.py py2app

steveharman commented 4 years ago

Could you explain how I accomplish item 1 in your list of steps please @wasbeer ?

Thanks

steveharman commented 4 years ago

I come bak to this from time to time, to see if the errors I have go away, but I think this is y final attempt.

And I get:

python3 setup.py py2app
running py2app
creating /Users/steveharman/radiobar/build/bdist.macosx-10.15-x86_64/python3.7-standalone
creating /Users/steveharman/radiobar/build/bdist.macosx-10.15-x86_64/python3.7-standalone/app
creating /Users/steveharman/radiobar/build/bdist.macosx-10.15-x86_64/python3.7-standalone/app/collect
creating /Users/steveharman/radiobar/build/bdist.macosx-10.15-x86_64/python3.7-standalone/app/temp
creating build/bdist.macosx-10.15-x86_64/python3.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.15-x86_64/python3.7-standalone/app/Frameworks
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    setup_requires=['py2app'],
  File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.19-py3.7.egg/py2app/build_app.py", line 838, in run
    self._run()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.19-py3.7.egg/py2app/build_app.py", line 1053, in _run
    self.run_normal()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.19-py3.7.egg/py2app/build_app.py", line 1146, in run_normal
    mf = self.get_modulefinder()
  File "/Users/steveharman/radiobar/.eggs/py2app-0.19-py3.7.egg/py2app/build_app.py", line 997, in get_modulefinder
    debug=debug,
  File "/Users/steveharman/radiobar/.eggs/modulegraph-0.17-py3.7.egg/modulegraph/find_modules.py", line 338, in find_modules
    find_needed_modules(mf, scripts, includes, packages)
  File "/Users/steveharman/radiobar/.eggs/modulegraph-0.17-py3.7.egg/modulegraph/find_modules.py", line 256, in find_needed_modules
    path = m.packagepath[0]
TypeError: 'NoneType' object is not subscriptable
mdbraber commented 4 years ago

@steveharman did you try pip3 install modulegraph?

steveharman commented 4 years ago

I don't know what modulegraph is but I used pip3 to install py2app. Is it relevant that I never get any success with the shortened version of py2app from terminal, only the full py2applet command

➜  radiobar git:(master) py2applet

usage: py2applet --make-setup [options...] script.py [data files...]
   or: py2applet [options...] script.py [data files...]
   or: py2applet --help

➜  radiobar git:(master) py2app
zsh: command not found: py2app
➜  radiobar git:(master)
mdbraber commented 4 years ago

py2app is not an independent command afaik (you run it through python setup.py py2app. py2applet is an independent command so what you have looks okay. I'm guessing it's some kind of versioning problem. Can you try installing the dev versions of the modules as mentioned here: https://mail.python.org/pipermail/pythonmac-sig/2008-September/020471.html

easy_install -U modulegraph==dev easy_install -U py2app==dev