'NoneType' object is not subscriptable ?
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
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.
Thanks @mdbraber - I just updated my ticket with a little more detail.
@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
@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)
- Run it again in interactive mode, i.e.
python3 -i setup.py py2app. Oncesetup.pyexits you will find yourself in a python prompt. - Run
from pdb import pm; pm(). You should now find yourself at a debug prompt. - 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.
- 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.
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. ;-)
@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?
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.
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
The following steps resulted in a working app for me:
-
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 -
Delete the setup.py and make a new one
py2applet --make-setup radiobar.py -
Build the app using py2app
python -i setup.py py2app
Could you explain how I accomplish item 1 in your list of steps please @wasbeer ?
Thanks
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.
- Fresh install of macOS
- Fresh install of python3
- Fresh install of vlc
- Fresh clone of the code [master]
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
@steveharman did you try pip3 install modulegraph?
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)
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