Errors trying to build distribution

I am not able to get a workable build of my game. I am new to Panda3d, but experienced programmer and somewhat experienced in python. I built a game that works fine, but cannot get a distribution build with setuptools.

Python 3.9 on OSX 10.15.7.
command: python3 setup.py bdist_apps

2 errors: OSX build (Museum.app) starts then exits immediately; Win build dies with errors.

Win:
1: missing modules (about 50) – does this mean I have to build on a Windows computer?
2: AttributeError: ‘array.array’ object has no attribute ‘fromstring’

OSX:
Double-click the 'Museum.app" gives no error but just exits.
Starting the terminal window inside the .app/Contents/MacOS gives this error:
:display(warning): Unable to load libpandagl.so: No error.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
File “main”, line 288, in
File “main”, line 38, in init
File “direct.showbase.ShowBase”, line 338, in init
File “direct.showbase.ShowBase”, line 1020, in openDefaultWindow
File “direct.showbase.ShowBase”, line 1055, in openMainWindow
File “direct.showbase.ShowBase”, line 765, in openWindow
File “direct.showbase.ShowBase”, line 745, in
File “direct.showbase.ShowBase”, line 817, in _doOpenWindow
File “direct.showbase.ShowBase”, line 646, in makeDefaultPipe
File “direct.directnotify.Notifier”, line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.

setup.exe:
from setuptools import setup

setup(
    name="Mixed Up Museum",
    options = {
        'build_apps': {
            'gui_apps': {'Museum': 'Maze.py'},
            'include_patterns': [
                '**/*.png',
                '**/*.jpg',
                '**/*.egg',
                '**/*.bam',
                '**/*.csv',
                '**/*.ogg',
            ],
        }
    }
)

and requirements.txt has panda3d

Further: If I only build for “macosx_10_9_x86_64”, then I get There are some missing modules: [‘AppKit’…(maybe a hundred more)
Previously I had seen that on the linux build.

Other notes:
checked Config.prc, (I have not edited it) it has
load-display pandagl
#load-display p3tinydisplay

It does not have a plugin_path, but I am not using any plugins that I am aware of.

OSX is screwy about its directories, is it possible Config.prc needs to be in a different place? (It is in ./Library/Developer/Panda3D/etc/Config.prc)

Where do I look for the problem? I have not touched any panda installation sources.

You don’t have the plugins section filled in.

Thank you, my bad, I missed that in the manual, thought I read it all.

But it made little difference. Still the long list of missing modules, still error out in the Win build. The difference is that on OSX the window starts up before exiting.

Running the terminal version directly shows a numpy error:
Original error was: dlopen(/Users/davidmarques/prog/panda/Maze/build/macosx_10_9_x86_64/Museum.app/Contents/MacOS/…/Frameworks/numpy.core._multiarray_umath.so, 2): Library not loaded: @loader_path/libopenblas.0.dylib
Referenced from: /Users/davidmarques/prog/panda/Maze/build/macosx_10_9_x86_64/Museum.app/Contents/Frameworks/numpy.core._multiarray_umath.so
Reason: image not found

But trying to install numpy gives: Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (1.19.4)

I assume this is a python config problem in my system. I do have numpy installed, maybe somehow a version mismatch?

It’s not that simple.

You must fill in the dependencies in the file requirements.txt

add: numpy and all the Python modules that were used when creating the game.

fromstring error - [AttributeError: 'array.array' object has no attribute 'fromstring'] When using setup.py

Ah. Add every item from my set of imports? Sorry, I did not understand that. Trying…

Are you using Panda4D 1.10.7 ? There was a bug that caused additional numpy libraries to not be included (https://github.com/panda3d/panda3d/issues/914) but it’s fixed in 1.10.7

My app is using numpy without issue and I don’t have numpy referenced in the setup.py, setuptools detect correctly the dependency.

Not every element, only what is installed as a module. For example, using pip.

You’re right, the modules must be defined in requirements.txt, but then setuptools detects what is needed :slight_smile:

I added numpy and pandas, but still the same error. I saw the script installing both for each build.

Have 1.10.7:
Requirement already satisfied: panda3d==1.10.7 in /Library/Developer/Panda3D (1.10.7)
The error is slighly different, actually, says that numpy requirement for pandas is not met:
Traceback (most recent call last):
File “main”, line 288, in
File “main”, line 108, in init
File “importlib._bootstrap”, line 1007, in _find_and_load
File “importlib._bootstrap”, line 986, in _find_and_load_unlocked
File “importlib._bootstrap”, line 680, in _load_unlocked
File “importlib._bootstrap”, line 838, in exec_module
File “Topics”, line 7, in
File “importlib._bootstrap”, line 1007, in _find_and_load
File “importlib._bootstrap”, line 986, in _find_and_load_unlocked
File “importlib._bootstrap”, line 680, in _load_unlocked
File “importlib._bootstrap”, line 838, in exec_module
File “pandas”, line 16, in
ImportError: Unable to import required dependencies:
numpy:

if I leave out pandas (and comment out reference to it), I get a different error that seems much more basic:

File “main”, line 288, in
File “main”, line 108, in init
File “importlib._bootstrap”, line 1007, in _find_and_load
File “importlib._bootstrap”, line 986, in _find_and_load_unlocked
File “importlib._bootstrap”, line 680, in _load_unlocked
File “importlib._bootstrap”, line 838, in exec_module
File “Topics”, line 11, in
File “importlib._bootstrap”, line 1007, in _find_and_load
File “importlib._bootstrap”, line 986, in _find_and_load_unlocked
File “importlib._bootstrap”, line 680, in _load_unlocked
File “importlib._bootstrap”, line 838, in exec_module
File “requests”, line 43, in
File “importlib._bootstrap”, line 1007, in _find_and_load
File “importlib._bootstrap”, line 986, in _find_and_load_unlocked
File “importlib._bootstrap”, line 680, in _load_unlocked
File “importlib._bootstrap”, line 838, in exec_module
File “urllib3”, line 13, in
File “importlib._bootstrap”, line 1007, in _find_and_load
File “importlib._bootstrap”, line 986, in _find_and_load_unlocked
File “importlib._bootstrap”, line 680, in _load_unlocked
File “importlib._bootstrap”, line 838, in exec_module
File “urllib3.connectionpool”, line 37, in
File “importlib._bootstrap”, line 1055, in _handle_fromlist
File “urllib3.packages.six”, line 91, in get
File “urllib3.packages.six”, line 113, in _resolve
File “urllib3.packages.six”, line 82, in _import_module
File “importlib._bootstrap”, line 1007, in _find_and_load
File “importlib._bootstrap”, line 984, in _find_and_load_unlocked
No module named ‘queue’

While running setup.y bdist_apps do you see a line :

Collecting numpy
  File was already downloaded /something/build/__whl_cache__/macosx_10_9_x86_64_cp37m/numpy-1.19.4-cp37-cp37m-macosx_10_9_x86_64.whl

?

Yes

Collecting numpy
File was already downloaded /Users/davidmarques/prog/panda/Maze/build/whl_cache/macosx_10_9_x86_64_cp39/numpy-1.19.4-cp39-cp39-macosx_10_9_x86_64.whl
Collecting panda3d
File was already downloaded /Users/davidmarques/prog/panda/Maze/build/whl_cache/macosx_10_9_x86_64_cp39/panda3d-1.10.7+opt-cp39-cp39-macosx_10_9_x86_64.whl
Successfully downloaded numpy panda3d

This worries me, though the http requests don’t happen until after first scene:

There are some missing modules: ['Cookie', 'OpenSSL.SSL', 'OpenSSL.crypto', 'StringIO', '__builtin__', '_winapi', 'backports.ssl_match_hostname', 'brotli', 'collections.Callable', 'collections.Mapping', 'collections.MutableMapping', 'cookielib', 'cryptography', 'cryptography.hazmat.backends.openssl', 'cryptography.hazmat.backends.openssl.x509', 'cryptography.x509', 'cryptography.x509.extensions', 'dummy_threading', 'packages.six.moves', 'packages.six.moves.http_client', 'packages.six.moves.urllib.parse', 'packages.ssl_match_hostname.CertificateError', 'packages.ssl_match_hostname.match_hostname', 'pep517', 'simplejson', 'socks', 'urllib.getproxies', 'urllib.getproxies_environment', 'urllib.proxy_bypass', 'urllib.proxy_bypass_environment', 'urllib.quote', 'urllib.quote_plus', 'urllib.unquote', 'urllib.unquote_plus', 'urllib.urlencode', 'urllib2', 'urlparse', 'util.SKIPPABLE_HEADERS', 'util.SKIP_HEADER', 'zipimport']

Are you directly importing numpyor is it a dependency of another library ? If that so, you might have to explicitly reference it as setuptools might not detect it. In the build_apps section you can add :

'include_modules': {'*': ['numpy'] }

or maybe 'numpy.*'

I do not directly import numpy, but I do import pandas. However, I have tried removing the pandas import (and numpy from requirements.txt) and then I get the error

ModuleNotFoundError: No module named ‘queue’

OK, got it to build. But I had to drop import of pandas and requests. How do I import them correctly? With the include_modules in setup?

putting that line:
‘include_modules’: {’’: [‘numpy’] } or ‘include_modules’:[‘numpy’] or ‘include_modules’:['numpy.’]
in setup.py does not make a difference, gives the same numpy errors.

Could you try and add explicitly numpy in requirements.txt and do an import numpy before importing pandas ?

I have numpy explicitly in reqiurements.txt. Putting import numpy before import pandas does not make a difference.

Please note that the program works fine from command line python.

I can change my approach to not use pandas, but I cannot avoid using http, so requests is more important.

Anyway, clearly a setuptools issue, not a panda3d issue, sorry.

No no, setuptools is indeed not a subsystyem of Panda3D, however Panda3D adds dedicated commands in setuptools to build the app and create the distribution. And the inclusion of thd external dependencies is done by the Panda3D commands.

Have you tried include_modules with the dependencies of requests ?
Could you make a small example that reproduce the problem ?

I have family duties right now, but I think the problem is simple: take any python program with these two (or equivalent) lines and then figure out how to to build with them:

include requests

response = requests.get(“http://www.ideategames.org/dcims/”+imgname)

If you can get that to work on any other (OSX?) build, I should be able to use the example.

I think it might have something to do with the different pythons installed on OSX. OSX needs 2.7, and I am running all this on 3.9. I have tried installing everything on 2.7 but getting some protection errors (OSX changed a lot of directory privileges in the last few versions), but I bet that has to do with the problem.